Sign in Go Pro

Storing Data in Android with Room

TypeConverter

11/13/2018

This lesson is for PRO members.

Upgrade today to get access to all the PRO lessons.

Unlock this lesson
Autoplay

Up next

Previous

About

Overview

In this lesson, we'll discuss what TypeConverters are, and describe when you might need to use them.

We'll add a new field to an entity, one with a data type that Room doesn't know how to persist. We'll see the error Room provides here, and walk you through how to add a TypeConverter to fix the problem.

Summary of Content:

  • What data types Room knows how to store
  • How to tell Room how to store complex objects, such as classes you've defined yourself
  • What a TypeConverter is, and how to define a function using the TypeConverter annotation
  • How to register a TypeConverter with Room, using the @TypeConverters annotation
  • What options you have for applying scope to a TypeConverter
  • When you'll see this error, and how to fix it. "Cannot figure out how to save this field into database. You can consider adding a type converter for it."
  • Writing type converters to allow us to persist a field of type Date to the database

Links:

Instructor

Links

Comments

There are no comments on this lesson, start the conversation below ...

>
You need to go PRO to post comments.

Lessons in Storing Data in Android with Room