[英]Room database throwing error after reinstalling - Room cannot verify the data integrity
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.我之前有 FirstTable,而 SecondTable 是新添加的。 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.我还在 AndroidManifest.xml 中给出了android:allowBackup="false"
。 I do not want to use fallbackToDestructiveMigration()
which clears my prepackaged db too.我不想使用fallbackToDestructiveMigration()
也清除我的预打包数据库。
I uninstalled the app in the emulator(API Level 29) and ran the app.我在模拟器(API 级别 29)中卸载了该应用程序并运行了该应用程序。 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.在预打包的数据库中包含新表(一个空表),然后它工作正常。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.