Sqlite Database deleted when I clear data from Application

三世轮回 提交于 2019-12-10 13:26:53

问题


I have created Sqlite database in app. when I clear data from settings->applications->manage applications the Sqlite db removed. any suggestions to keep sqlite database as it is.


回答1:


When you press Clear Data from the Android application manager its supposed to remove everything related to the app such as preferences, databases, caches etc the only thing that gets left is the app so when you re-launch it behaves as if it was just installed.

If you want to allow the user to clear the data but keep the database then there should be an option in the menu that removes the shared preferences but doesn't do anything with the database.

Hope this helps.




回答2:


Why would you want to keep the data when the user wants to clear everything. It is not suggested you keep the db.

I would suggest you use the sd card to store images/text files with the adequate permission from the user.




回答3:


Android's SQLite is intented for local app data storage. When you opt to wipe your app's data, this data is wiped (as expected).

If you want to persist DB data, look into external storage (eg. the late Parse.com, or MS's Azure). You'll be making network calls, your local data will still be wiped, and you'll need to have a way to link your app back up with the external data post-local-wipe (eg. logging in) but your external data will survive an app data clear.

The "linking up" part can be mitigated as well depending on your use case, eg. Google Play Games' data services is tied to your Google Play id and will resync after an app wipe.



来源:https://stackoverflow.com/questions/16476623/sqlite-database-deleted-when-i-clear-data-from-application

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!