@Entity(tableName = "routines")
data class Routine (
// other fields ...
@ColumnInfo(name = "date")
var date: LocalDate = LocalDate.now()
)
Room provides functionality for converting between primitive and boxed types but doesn't allow for object references between entities.
Use type converters
Sometimes, you need your app to store a custom data type in a single database column. You support custom types by providing type converters, which are methods that tell Room how to convert custom types to and from known types that Room can persist. You identify type converters by using the @TypeConverter annotation.
If you're building your app using Android Gradle plugin 4.0.0 or higher, the plugin extends support for using a number of Java 8 language APIs without requiring a minimum API level for your app.
This additional support for older platform versions is possible because plugin 4.0.0 and higher extend the desugaring engine to also desugar Java language APIs. So, you can include standard language APIs that were available only in recent Android releases (such as
java.util.streams
) in apps that support older versions of Android.