i have local sqlite
database on android app , i'm bit confused on how manage when app gets updated. need keep data stored in db whenever update app think i'm going add columns , tables. what's best practice so?
my idea check db version , if matches old version call method add new columns/tables , upgrade version, correct approach or there's else consider?
@override public void onupgrade(sqlitedatabase db, int oldversion, int newversion) { if (oldversion < 2) { db.execsql(database_alter_team_1); } if (oldversion < 3) { db.execsql(database_alter_team_2); } if (oldversion < 4) { db.execsql(database_alter_team_3); } }
this best way of handling onupgrade(). because users may not update versions, in cases best approach.
Comments
Post a Comment