I\'m evaluating GreenDAO for consideration in a commercial Android app I will be working on and wanted to determine the migration path for schema updates.
Am I corre
Pedro Okawa' solution is correct, but you need to write your "UpgradeHelper" to extend "OpenHelper" because DaoMaster is overwritten each time you re-generate DAO code.
Example:
public class UpgradeHelper extends DaoMaster.OpenHelper {
public UpgradeHelper(Context context, String name, SQLiteDatabase.CursorFactory factory) {
super(context, name, factory);
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
Log.i("greenDAO", "Upgrading schema from version " + oldVersion + " to " + newVersion + " by migrating all tables data");
MigrationHelper.getInstance().migrate(db,
UserDao.class,
ItemDao.class,
AnotherClassToGenerateDao.class);
}
}