let\'s assume I have a database table test_table with 2 columns and a corresponding create script in the SQLiteOpenHelper:
DB_VERSION = 1:
public void onCrea
below psuedo code shows increamental upgrade
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
switch(oldVersion) {
case 2:
//upgrade logic from version 2 to 3
case 3:
//upgrade logic from version 3 to 4
case 4:
//upgrade logic from version 4 to 5
break;
default:
throw new IllegalStateException(
"onUpgrade() with unknown oldVersion" + oldVersion));
}
}
By incremental upgrade i mean - Notice the missing break statement in case 2 and 3
say if the old version is 2 and new version is 4, then the logic will upgrade the database from 2 to 3 and then to 4
if old version is 3 and new version is 4, it will just run the upgrade logic for 3 to 4
keep adding new cases for every new database version upgrade that will do the increamental changes