I have an app, where I use SQLite database, provided by me, so it is fixed and the user will not update anything in the database. Only results will be shown from that database.
The problem is - I am creating that database programatically ONLY on first run of the app:
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
if(!prefs.getBoolean("firstTime", false)) {
final DatabaseHelper myDb;
myDb = new DatabaseHelper(this);
myDb.deltab();
myDb.insertData("Josh","Smith","012345678","something","something","something");myDb.insertData("Josh","Smith","012345678","something","something","something"); }
SharedPreferences.Editor editor = prefs.edit();
editor.putBoolean("firstTime",true);
editor.apply();
First I drop the table (just to be sure it will create it from start) and then I create it and insert the data.
This is working fine on first app run.
But if I need to add some more data into that table in the future, or change any existing data in the next app version, how can I do that?
If the user downloads the new version of the app, the firstTime condition is not going to run, because he already started the old app before and by upgrading the version the sharedpreferences are not reset.