-
Notifications
You must be signed in to change notification settings - Fork 1
UpgradeHelper
nmc9 edited this page Apr 30, 2018
·
1 revision
public class Upgrade extends UpgradeHelper {
public Upgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
super(db, oldVersion, newVersion);
}
//Logic for what to do when the app is upgraded
@Override
public void upgrade(DatabaseHelper database) {
switch (oldVersion) {
case 2:
case 3:
break;
default:
for (TableHelper t : database.all_tables()) {
DropTable dropTable = new DropTable(t.table_name());
Database.megaSafeDropTable(dropTable.ImSure().ifExists(), db);
Database.megaCreateTable(t.CREATE_TABLE(), db);
}
}
}
}
This method is called when the database is upgraded. Put all your logic for upgrading in this function. It's recommended to delete the tables and recreate if the version number is not know or recorded.