A
A
Alexander Sinitsyn2018-02-15 14:39:21
Android
Alexander Sinitsyn, 2018-02-15 14:39:21

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

2 answer(s)
I
Igor Shevchenko, 2018-02-22
@a_u_sinitsin

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();
    }
}

G
GavriKos, 2018-02-15
@GavriKos

https://stackoverflow.com/questions/4406067/how-to...
first line of google

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question