I use GreenDao as my ORM. I want to migrate the schema from oldversion to the new version. I use this link to implement my mygration. So I wrote my own OpenHelper class and put it in another package. I implement the onUpgrade method as follows:
public class UpgradeHelper extends OpenHelper {
public UpgradeHelper(Context context, String name, CursorFactory factory) {
super(context, name, factory);
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
Log.i("greenDAO", "My Upgrade Helper -------- Upgrading schema from version " + oldVersion + " to " + newVersion + " by dropping all tables");
switch (newVersion) {
case 2:
new MigrateV1ToV2().applyMigration(db, oldVersion);
break;
case 3:
new MigrateV2ToV3().applyMigration(db, oldVersion);
break;
default:
return;
}
}
}
But this method was never called when updating the database version from 1 to 2. Also, I can not change the onUpgrade () method in the created DaoMaster class, because it is generated automatically. When I update SCHEMA_VERSION, the onUpgrade () method is called, but it is in the DaoMaster class, and I cannot change it.