May 2022
Intermediate to advanced
688 pages
20h 12m
English
Next, open Crime.kt and give Crime a property to hold the name of a suspect. Provide a default value – an empty string – so that you do not have to update places in your codebase where you create a Crime.
Listing 16.3 Adding a suspect property (Crime.kt)
@Entity
data class Crime(
@PrimaryKey val id: UUID,
val title: String,
val date: Date,
val isSolved: Boolean,
val suspect: String = ""
)
Since you updated your Crime class, and Room uses that class to create database tables for you, you need to make some changes to your database as well. Specifically, you need to increment the version of your CrimeDatabase class and tell Room how to migrate your database between the versions.
Room uses a versioning ...
Read now
Unlock full access