Sqlite database is deleted when I clear data from application

I created the Sqlite database in the application. when I delete data from settings->applications->manage applications deleted Sqlite db. any suggestions for saving the Sqlite database.

+4
source share
3 answers

When you click Clear Data from the Android application manager, it should delete everything related to the application, for example, preferences, databases, caches, etc. The only thing that remains is the application, so when you restart it, it behaves as if it was just installed.

If you want to allow the user to clear the data, but save the database, then the menu should have an option that removes the general settings, but does nothing with the database.

Hope this helps.

+9
source

Why do you want to save data when the user wants to clear everything. It is not recommended to keep db.

I suggest you use an SD card to store images / text files with the appropriate user permission.

0
source

Android SQLite is designed to store local application data. When you decide to erase your application data, that data is erased (as expected).

If you want to save database data, look at external storage (for example, late Parse.com or MS Azure). You will make network calls, your local data will still be deleted, and you will need to associate your application with external post-local-wipe data (for example, logging in), but your external data will withstand the application data.

Part of the β€œbinding” can also be reduced depending on your use case, for example. Google Play Games data services are tied to your Google Play ID and will re-sync after erasing the application.

0
source

Source: https://habr.com/ru/post/1480053/


All Articles