-3

This is the error I got,

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.
                                                                                at android.arch.persistence.room.RoomOpenHelper.checkIdentity(RoomOpenHelper.java:135)
                                                                                at android.arch.persistence.room.RoomOpenHelper.onOpen(RoomOpenHelper.java:115)
                                                                                at android.arch.persistence.db.framework.FrameworkSQLiteOpenHelper$OpenHelper.onOpen(FrameworkSQLiteOpenHelper.java:151)
                                                                                at android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked(SQLiteOpenHelper.java:411)
                                                                                at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:298)
                                                                                at android.arch.persistence.db.framework.FrameworkSQLiteOpenHelper$OpenHelper.getWritableSupportDatabase(FrameworkSQLiteOpenHelper.java:96)
                                                                                at android.arch.persistence.db.framework.FrameworkSQLiteOpenHelper$OpenHelper.getWritableSupportDatabase(FrameworkSQLiteOpenHelper.java:100)
                                                                                at android.arch.persistence.db.framework.FrameworkSQLiteOpenHelper.getWritableDatabase(FrameworkSQLiteOpenHelper.java:54)
                                                                                at android.arch.persistence.room.RoomDatabase.query(RoomDatabase.java:233)

My Database class is

@Database(entities = SliderImageModel.class, version = DbConfig.Version_SliderImage_84, exportSchema = false)
public abstract class SliderImageDatabase extends RoomDatabase {

    public abstract SliderImageDao sliderImageDao();

    public static SliderImageDatabase INSTANCE;

    private static final Migration MIGRATION_1_84 = new Migration(DbConfig.Version_NewsAnnouncement_1, DbConfig.Version_SliderImage_84) {
        @Override
        public void migrate(@NonNull SupportSQLiteDatabase database) {
            database.execSQL(SLIDERIMAGE);
        }
    };
    private static final Migration MIGRATION_2_84 = new Migration(DbConfig.Version_SchoolEvent_2, DbConfig.Version_SliderImage_84) {
        @Override
        public void migrate(@NonNull SupportSQLiteDatabase database) {
            database.execSQL(SLIDERIMAGE);
        }
    };
MikeT
  • 51,415
  • 16
  • 49
  • 68
  • 1
    uninstall the app and reinstall or update your database version. – a_local_nobody Nov 22 '19 at 05:54
  • this is not how you ask a question on SO though. please look at [how to ask](https://stackoverflow.com/help/how-to-ask) and the [tour](https://stackoverflow.com/tour) – a_local_nobody Nov 22 '19 at 05:55
  • 4
    Possible duplicate of [Room cannot verify the data integrity](https://stackoverflow.com/questions/44197309/room-cannot-verify-the-data-integrity) – Saurabh Thorat Nov 22 '19 at 05:55
  • i had tried uninstalling the app / cache clear and also increased the version code – Yarsha Soft Nov 22 '19 at 05:56
  • i did migrations like this @Database(entities = SliderImageModel.class, version = DbConfig.Version_SliderImage_84, exportSchema = false) public abstract class SliderImageDatabase extends RoomDatabase { public abstract SliderImageDao sliderImageDao(); public static SliderImageDatabase INSTANCE; private static final Migration MIGRATION_1_84 = new Migration(DbConfig.Version_NewsAnnouncement_1, DbConfig.Version_SliderImage_84) { @Override public void migrate(@NonNull SupportSQLiteDatabase database) { database.execSQL(SLIDERIMAGE); } – Yarsha Soft Nov 22 '19 at 06:20
  • please don't post your code in comments, instead, [edit](https://stackoverflow.com/posts/58988255/edit) your original post to add it – a_local_nobody Nov 22 '19 at 06:22
  • i couldn't add this database build code in the post – Yarsha Soft Nov 22 '19 at 06:25

1 Answers1

-1

Try with below by increasing your version number as mentioned,

@Database(entities = pojo.class, exportSchema= false, version=2 )
Sajith
  • 713
  • 6
  • 21