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
TypeConverteris, and how to define a function using the
- How to register a
TypeConverterwith Room, using the
- What options you have for applying scope to a
- 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
Dateto the database