Reputation: 3299
I have an app which makes a database by Room. Then I move the database to the server to populated. While updating or initializing the app, the populated database is downloaded by the app. But when I want to use it by Room I get an error message:
A migration from 2 to 1 is necessary. Please provide a Migration in the builder or call fallbackToDestructiveMigration in the builder in which case Room will re-create all of the tables.
I cleaned whole build folder then I did all again. But I get the same error again!
Where I get error is:
String SALE_DATABASE_NAME = "SaleDatabase.db";
SaleDatabase saleDatabase = Room.databaseBuilder(this,
SaleDatabase.class, SALE_DATABASE_NAME)
//.fallbackToDestructiveMigration()
.allowMainThreadQueries()
.build();
saleDatabase.getPathDao().getPaths(); //Getting error
Database class:
@Database(entities = {OrderEntity.class, OrderDetailEntity.class
, CardIndexDetailEntity.class, CardIndexEntity.class
, CategoryEntity.class, CodingEntity.class
, CustomerBasicEntity.class, CustomerBuyEntity.class
, CustomerChequeEntity.class, CustomerCreditEntity.class
, PathEntity.class, UnvisitedCustomerReasonEntity.class
, ProfileCategoryEntity.class, SubCategoryDetailEntity.class
, SubCategoryEntity.class, ReasonEntity.class}, version = 1)
public abstract class SaleDatabase extends RoomDatabase{
public abstract PathDao getPathDao();
@Override
protected SupportSQLiteOpenHelper createOpenHelper(DatabaseConfiguration config) {
return null;
}
@Override
protected InvalidationTracker createInvalidationTracker() {
return null;
}
}
My hash code in both database and SaleDatabase_Impl.java class is same.
So my questions are:
Upvotes: 4
Views: 898
Reputation: 2128
I solved this way:
android:allowBackup="false"
Upvotes: 3