Reputation: 357
I have followed the guidelines of this document of Android and implemented backup manager. I am able to back up and restore the sharedpref using this framework, however when I uninstall the application and then when I switch off and then switch on my mobile the sharedpref is not restored. In the android document, I got a warning:
Warning! When backup is disabled, the current backup transport will explicitly wipe the entire active data set from its backend storage.
This is so that when a user says they do not want their data backed up, the Backup Manager respects that wish. No further data will be saved from the device, and no restore operations will be possible, unless the Backup Manager is re-enabled (either through Settings or through the above bmgr command).
So why does my shared pref get deleted when I uninstall and turn off my mobile?
Upvotes: 0
Views: 1198
Reputation: 1007359
I am able to back up and restore the sharedpref using this framework, however when I uninstall the application and then when I switch off and then switch on my mobile the sharedpref is not restored.
Of course not. You uninstalled the application. All of your files on internal storage are deleted when you uninstall the application.
So why does my shared pref get deleted when I uninstall and turn off my mobile?
Because you uninstalled the application.
In the first paragraph of the page you linked to in your comment, you will find:
If a user performs a factory reset or converts to a new Android-powered device, the system automatically restores your backup data when the application is re-installed.
By your own admission, this is not what you did. You did not "perform a factory reset or convert to a new Android-powered device", and your app was not installed at the time on the (original) device.
Upvotes: 2