4

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?

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Khawar Raza
  • 15,870
  • 24
  • 70
  • 127
  • Store it on the SDCard, or, for Android 2.2+, include a backup-agent for the Android backup service provided by Google? – Jens Oct 18 '11 at 11:48

2 Answers2

-3

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.

Venky
  • 11,049
  • 5
  • 49
  • 66
-3

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

flyhalf8610
  • 94
  • 2
  • 8
  • 2
    A ContentProvider is by no means a persistant storage, it typically uses an SQLiteOpenHelper that will gladly put its database file in the database folder of your app - which will be wiped when you nuke your app. – Jens Oct 18 '11 at 12:05