Why SQLite database cleared on clearing data of application from Application Management?

丶灬走出姿态 提交于 2019-12-10 17:38:47

问题


I created a simple database application using SQLite which first creates database and then allow users to insert and view inserted records. But when I clear data from Application Settings of android phone, the data of the database is also cleared. Why is this and is there any way to preserve data even the user clear it from Settings?


回答1:


When you create a database, Android create a new database file in the /databases folder. When you delete data, Android cancel every files created in the application folder, included the /database folder. You should use a persistent DataBase like the Content Provider




回答2:


You can use Content Provider so that it will retain Data at all time , also it will allow you to share your Data between Different Application :

Check this Content Providers.

Also check this Sample for using Content Provider.



来源:https://stackoverflow.com/questions/7806629/why-sqlite-database-cleared-on-clearing-data-of-application-from-application-man

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