Assume i have my app's database version 1 running on some user device for a while.
in the meantime i increment database version to 2, and then to 3 and handle onUpgrade like that :
if (oldVersion == 1 && newVersion == 2) {
db.execSQL(String.format("ALTER TABLE ... ADD .. text", ));
} else if (oldVersion == 2 && newVersion == 3) {
db.execSQL(String.format("ALTER TABLE ... ADD .. text", ));
}
When that user upgrades my app, will both blocks be executed?
i guess you can use:
if (oldVersion == 1) {
do stuff;
oldVersion = oldVersion + 1;
}
if (oldVersion == 2) {
do stuff;
oldVersion = oldVersion + 1;
}
or use a switch.