Answer the question
In order to leave comments, you need to log in
How to remove the Sqlite database from the application if you decide not to use it?
There is an application already on the market. The base is used for the functionality that I decided to remove.
It is necessary to somehow take some data from it during the update and delete it.
How to do it right?
So far, I've only come up with an option with a flag in SharedPreferences.
- If it is not there, then connect the database,
- check the previous version in it, if it is less than the current one, then take the data, delete the database,
- set the flag.
- Do not connect the base during the next launches.
- When all users switch to the new version, remove the flag check and cut the base completely.
Answer the question
In order to leave comments, you need to log in
If the standard SQLiteOpenHelper was used, then the task is solved by adding the necessary code to the onUpgrade method
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
if (oldVersion == 1 && newVesion == 2) {
moveOldDataToNewStructure();
deleteOldDataBase();
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question