Room is unable to store data types that are not primitive. We can either add @Embedded.
(See https://developer.android.com/reference/android/arch/persistence/room/Embedded)
There is a utilty to use type convertors with Moshi and Room. The convertor class can be used for conversions. To use this
- Make sure you have all the dependencies of Room loaded
- Add the RoomConvertor Class to the Android Project
- Make sure to edit it as per requirements
- Add the following line to the data class
@TypeConverters(value = [RoomConvertor::class])
- To reference this in the database, add
@TypeConverters(RoomConvertor::class)
in the Database file