I am in the project development phase. So, I basically do not need migrations at this point in time. I had FirstTable before and SecondTable is the newly added one. I already had prepackaged db also. Below is the code used.
@Database(
entities = [
FirstTable::class,
SecondTable::class
],
version = 1,
exportSchema = true
)
abstract class MyDatabase : RoomDatabase() {
companion object {
private const val databaseName = "my-db"
private const val prepackagedDB = "prepackaged-db"
fun buildDatabase(context: Context): MyDatabase {
return Room.databaseBuilder(context, MyDatabase::class.java, databaseName)
.createFromAsset(prepackagedDB)
.build()
}
}
}
I have also given android:allowBackup="false"
in AndroidManifest.xml. I do not want to use fallbackToDestructiveMigration()
which clears my prepackaged db too.
I uninstalled the app in the emulator(API Level 29) and ran the app. I am getting this error.
I am not able to understand why reinstalling is causing this issue. Could someone let me know what I went wrong?
Included the new table(an empty one) in the prepackaged DB and then it's working fine.