已解决Android Room: Room cannot verify the data integrity.

我对自己也是无语了,逗笑我了。

灵感来源于这篇博文

http://t.csdnimg.cn/jdvlj

我擅自主张改变了实体表的名

@Entity(tableName = "tb_crime")
data class Crime(
    @PrimaryKey val id: UUID,
    val title: String,
    val date: Date,
    val isSolved: Boolean
)

书上的代码是这个样子的

@Entity
data class Crime(
    @PrimaryKey val id: UUID,
    val title: String,
    val date: Date,
    val isSolved: Boolean
)

就因为一个表名我在导入预数据时候一直报错

 java.lang.IllegalStateException: Room cannot verify the data integrity. Looks like you've changed schema but forgot to update the version number. You can simply fix this by increasing the version number. Expected identity hash: 74458567a7d4779fbce50002418f2039, found: 81f2ccd0cbc88ef0696bcce4b5d5c0e9

改了表名为默认名之后就欧克了

E/AndroidRuntime: FATAL EXCEPTION: Thread-2 Process: com.example.cameradiary, PID: 21990 java.lang.IllegalStateException: Room cannot verify the data integrity. Looks like you've changed schema but forgot to update the version number. You can simply fix this by increasing the version number. Expected identity hash: d0562aadd9063ca2a0141765861a8b25, found: 903c8b01c1005d9d530310defd042e19 at androidx.room.RoomOpenHelper.checkIdentity(RoomOpenHelper.kt:147) at androidx.room.RoomOpenHelper.onOpen(RoomOpenHelper.kt:128) at androidx.sqlite.db.framework.FrameworkSQLiteOpenHelper$OpenHelper.onOpen(FrameworkSQLiteOpenHelper.kt:287) at android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked(SQLiteOpenHelper.java:428) at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:317) at androidx.sqlite.db.framework.FrameworkSQLiteOpenHelper$OpenHelper.getWritableOrReadableDatabase(FrameworkSQLiteOpenHelper.kt:232) at androidx.sqlite.db.framework.FrameworkSQLiteOpenHelper$OpenHelper.innerGetDatabase(FrameworkSQLiteOpenHelper.kt:190) at androidx.sqlite.db.framework.FrameworkSQLiteOpenHelper$OpenHelper.getSupportDatabase(FrameworkSQLiteOpenHelper.kt:151) at androidx.sqlite.db.framework.FrameworkSQLiteOpenHelper.getWritableDatabase(FrameworkSQLiteOpenHelper.kt:104) at androidx.room.RoomDatabase.inTransaction(RoomDatabase.kt:638) at androidx.room.RoomDatabase.assertNotSuspendingTransaction(RoomDatabase.kt:457) at com.example.cameradiary.userDAO_Impl.getALLUsers(userDAO_Impl.java:70) at com.example.cameradiary.SecondActivity$1.run(SecondActivity.java:60)
05-25
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值