I\'m actually developing an app which is using ORMLite library (which is wonderful btw) but I\'m a beginner using it.
I have a question about the update of the datab
I do it this way:
@Override
public void onUpgrade(SQLiteDatabase database, ConnectionSource connectionSource, int oldVersion, int newVersion) {
switch (oldVersion) {
case 1:
updateFromVersion1(database, connectionSource, oldVersion, newVersion);
break;
case 2:
updateFromVersion2(database, connectionSource, oldVersion, newVersion);
break;
default:
// no updates needed
break;
}
}
private void updateFromVersion1(SQLiteDatabase database, ConnectionSource connectionSource, int oldVersion, int newVersion) {
// do some stuff here
onUpgrade(database, connectionSource, oldVersion + 1, newVersion);
}
private void updateFromVersion2(SQLiteDatabase database, ConnectionSource connectionSource, int oldVersion, int newVersion) {
// do some stuff here
onUpgrade(database, connectionSource, oldVersion + 1, newVersion);
}
This will incrementally update the users db independent from which db version he is coming.