TypeConverters



Specifies additional type converters that Room can use. The TypeConverter functions are added to the scope of the element so if you put it on a class / interface, all functions / properties in that class will be able to use the converters.

@TypeConverters can only be used to convert columns / properties, hence cannot be used by a function to convert a row return value such as DAO function that query rows, for such cases use DaoReturnTypeConverters.

  • If you put it on a Database, all DAOs and entities in that database will be able to use it.

  • If you put it on a Dao, all functions in the DAO will be able to use it.

  • If you put it on an Entity, all properties of the entity will be able to use it.

  • If you put it on a data object class, all properties of the data class will be able to use it.

  • If you put it on an Entity property, only that property will be able to use it.

  • If you put it on a Dao function, all parameters of the function will be able to use it.

  • If you put it on a Dao function parameter, just that property will be able to use it.

Summary

Public constructors

TypeConverters(
    vararg value: KClass<*>,
    builtInTypeConverters: BuiltInTypeConverters
)
Cmn

Public properties

BuiltInTypeConverters

Configure whether Room can use various built in converters for common types.

Cmn
Array<KClass<*>>

The list of type converter classes.

Cmn

Public constructors

TypeConverters

TypeConverters(
    vararg value: KClass<*> = [],
    builtInTypeConverters: BuiltInTypeConverters = BuiltInTypeConverters()
)

Public properties

builtInTypeConverters

val builtInTypeConvertersBuiltInTypeConverters

Configure whether Room can use various built in converters for common types. See BuiltInTypeConverters for details.

value

val valueArray<KClass<*>>

The list of type converter classes. If converter class is not an object Room will create an instance of these classes.

Returns
Array<KClass<*>>

The list of classes that contains the converter functions.