Finally, I managed to delve into it myself and realized that it is quite easy to add a new table, saving the data in the old tables.
DISCLAIMER . Although I understand that this implementation is specific to my scenario, I think it is useful for someone like me who used the Android ORM tool (greenDao) exclusively to work with SQLite on Android. I understand that this is quite common for those of you who wrote your own table creation queries from the very beginning, but for those who were protected from the courage to use SQLite DB with Android, I think this example will be useful.
ANSWER: You can either modify the inner class DevOpenHelper, or create your own class. I decided to change DevOpenHelper for a while so that my example is simple - however, note that if you restore your greendao classes, DevOpenHelper will be overwritten. It would be better to create your own class, for example "MyOpenHelper", and use it instead.
Prior to my changes, DevOpenHelper.onUpgrade looked like this:
@Override public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { Log.i("greenDAO", "Upgrading schema from version " + oldVersion + " to " + newVersion + " by dropping all tables"); dropAllTables(db, true); onCreate(db); }
Instead of dropping all tables, take a look at the createAllTables method, which is automatically generated by GreenDao.
Rewrite onUpgrade to check if "oldVersion" is the one you want to upgrade, and then call the createTable methods on the "new" tables. This is what my onUpgrade method looks like:
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { Log.i("greenDAO", "Upgrading schema from version " + oldVersion + " to " +
Adding a new column will be similar, except that you will need to write some SQL or take a look at the automatically generated SQL create statements from greenDao and use them.
To add one new column (NEW_COLUMN, assuming its type is INTEGER) to the existing table (EXISTING_TABLE), do the following:
db.execSQL("ALTER TABLE 'EXISTING_TABLE' ADD 'NEW_COLUMN' INTEGER");
For me right now all I had to do was add new tables so that it turned out to be pretty straightforward. Hope someone finds this helpful.