简体   繁体   English

重新安装后房间数据库抛出错误 - 房间无法验证数据完整性

[英]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.

相关问题 Room 无法验证数据完整性 - Room cannot verify the data integrity Room 无法验证 Android 中的数据完整性 - Room cannot verify the data integrity in Android 遇到错误,即使添加fallbackToDestructiveMigration()之后,Room仍无法验证数据完整性。 - Getting error Room cannot verify the data integrity… even after adding fallbackToDestructiveMigration() 即使在重新安装后,ROOM 数据库中的数据也不会被删除 - Even after reinstalling data is not removed in ROOM database 将第二个 Room 数据库添加到我的应用程序会导致异常:“原因:java.lang.IllegalStateException:Room 无法验证数据完整性” - Adding second Room database to my app causes exception: " Caused by: java.lang.IllegalStateException: Room cannot verify the data integrity" Room 无法验证数据完整性,但我启用了破坏性迁移 - Room cannot verify data integrity but I have desctructive migration enabled Room 重新打开应用时无法验证数据完整性 - Room cannot verify the data integrity when re open the app Room 无法验证数据完整性,版本号已更改 - Room cannot verify the data integrity, versionnumber already changed Room 无法验证数据完整性,即使在卸载应用程序然后重新安装后也是如此 - Room cannot verify the data integrity, even after uninstalling app then re-installing 在库模块内部清理房间DB。 房间无法验证数据的完整性 - Clearing room DB when inside library module. Room cannot verify the data integrity
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM