Pankaj Kharche
Pankaj Kharche

Reputation: 1329

Sqlite Database deleted when I clear data from Application

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.

Upvotes: 8

Views: 12679

Answers (3)

Tom
Tom

Reputation: 7804

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.

Upvotes: 1

Boardy
Boardy

Reputation: 36225

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.

Upvotes: 16

Aditya Kushwaha
Aditya Kushwaha

Reputation: 837

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.

Upvotes: 0

Related Questions