Room Cannot Verify the Data Integrity

Room cannot verify the data integrity

Aniruddh Parihar 's answer gave me a hint and it solved.

Search for a class where you have extended RoomDatabase. There you will find version like below :

@Database(entities = {YourEntity.class}, version = 1)

just increase the version and problem is solved.

Room cannot verify the data integrity, versionnumber already changed

I believe that your issue is that you are importing the database from the assets and that the version number has been set to 1 in the imported database.

That is first Room is detecting that it cannot verify the data integrity because there the room_master_table table doesn't exist in the imported database.

  • Otherwise Room checks the hash stored in the database against the value in the APK if they are not the same then the schema has changed.

Then Room finds that the database has a version number of 1 (as is stored in the header of the database file) and hence it saying that the version number has been changed. This being the real issue rather than the unable to verify the data integrity.

I believe that you need to change the version number to 0 in the database being imported. That is open it in DBBeaver, click on the Edit Pragmas and change the version number from 1 to 0. e.g. :-

Sample Image

Room cannot verify the data integrity when re open the app

Everything clearly mentioned in

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.

All you need to is increase version and set exportSchema to false

from

@Database(entities = [Type::class], version = 3)

to

@Database(entities = [Type::class], version = 4, exportSchema = false)

Note

@Database creates another db if you want all tables belongs same db
then include them into one db. you should not create new db for each
table

Room cannot verify the data integrity in Android

If you're only developing the application at the moment, it means that you are not on Production and uninstalling the app from device and install it again will work as required.



Related Topics



Leave a reply



Submit