问题
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