Reputation: 1227
I wanted to know whether reinstallation of app deletes SQLiteDatabase or SharedPreferences in Android. Also under what circumstances does it gets deleted. Application will be downloaded from server & installed. If it does get deleted what should we do to take a backup & restore it again?
Please help...
Upvotes: 5
Views: 3062
Reputation: 6746
SharedPreferences
and SQLiteDatabase
are deleted when you
If you want to restore your SharedPreferences
and SQLiteDatabase
when your app is reinstalled then you should add a BackupAgentHelper
to your app. Together with the SharedPreferenceBackupHelper
, it backups the SharedPreferences
and SQLiteDatabase
to the cloud (if the device supports it). When the app is reinstalled the data is restored.
See:
BackupAgentHelper
SharedPreferenceHelper (contains all the code you need to implement it)
general Backup guide
Just let me know if it worked for you. Hope it Helps :) Cheers.
Upvotes: 0
Reputation: 7384
Updating your app (installing newer or the same version) will keep you preferences and all data, unless you do not intentionally delete them in your code.. But if you uninstall the app before installing it again, then yes, all your data will be gone..
In Android Debug Bridge you can specify whether should you install it over the existing installation, or do a clean install with the -r flag (adb install your.apk
/ adb install -r your.apk
)
Upvotes: 5
Reputation: 3585
No... Database and SharedPreferences will not be deleted if one reinstall the app. They get deleted when some one uninstall it or clear data from settings menu of device...
Upvotes: 11