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. :-
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
How to Import Contacts from Phonebook to Our Application
Out of Memory While Creating Bitmaps on Device
Loading All the Images from Gallery into the Application in Android
Achartengine - Can't Figure How to Use Dates as X Axis - the File I Save Is Empty
Sliding Navigation Drawer Not Handling Clicks on Menu Items Android
Connectivity_Action Intent Received Twice When Wifi Connected
Android Task Affinity Explanation
Android Recyclerview: Change Layout File List to Grid Onoptionitemselected
Configuration on Demand Is Not Supported by the Current Version of the Android Gradle Plugin
How to Move Main Content with Drawer Layout Left Side
Should Accessing Sharedpreferences Be Done Off the UI Thread
Failure [Install_Failed_Update_Incompatible] Even If App Appears to Not Be Installed
Custom Global Application Class Breaks with "Android.App.Application Cannot Be Cast To"
Cordova Platform Add Android Not Working While Listing Android Targets
Bitmap Too Large to Be Uploaded into a Texture
Google Play Services Out of Date. Requires 11011000 But Found 10289574
How to Use Asynctask to Display a Progress Bar That Counts Down