Application restored some data in Shared Preference even after reinstall

Updated 17 August 2017


Have you ever wondered that despite uninstalling your application there is some data in your application when you reinstall it?

All we think is that the data was somewhere in shared preference and it was not deleted when we uninstalled the application.But that is simply not the case.

The shared preference is definitely deleted when the application is uninstalled. So what is the cause for this and how do we rectify it.


The Reason for this unwanted data is not the Shared Preference but is the “BackupManager”.

Since Android API 23 ( or Android “6.0” or Android “Marshmellow”) the BackupManager stores all the data of an application including the Shared preference on the cloud. Thus when your application is reinstalled, the shared preference data is restored.

A key point here to note is that the process of backup is like a black-box. We cannot know when it started, how it started and when will next cycle of backup occur. So if you are thinking of disabling backup process, or to set the shared preference data just before backup that is perhaps not possible for now.

Another key point to note is that when we create an application in android, in the manifest file the key “allowBackup” is set to true by default.


Solution 1: Your App Should warn the user to disable the Automatic Restore feature on the Android device. For this, the user needs to go to the path
Settings–> Backup & Reset–>Automatic restore  and then turn the switch off.
But this is not recommended, as this will turn off the automatic backup feature for all the applications installed on the device.

Solution 2: Go to your Manifest File. In the application tag, find the attribute “allowBackup” and set it to false.

On the precautionary note, you can also check for keys “fullBackupContent” and “fullBackupOnly”. and set them to false.

And “tools:replace” =”android:allowBackup” add this line too.
It is Done.


For further help regarding this, you can check the official document here.

That’s all for now.

We can also explicitly set the rules for what data should be included in the auto backup, which we will see some another time.
Also, we can externally set up a backupAgent and store the data we want to save after disabling the automatic BackUp process, which we will also learn some other time.

Keep coding and Keep Sharing 🙂


. . .

Leave a Comment

Your email address will not be published. Required fields are marked*


  • Muhammad Zeeshan Aslam
    Thanks for sharing this.
    • anchit (Moderator)
      Your Welcome
  • Yasir Tanveer
    • anchit (Moderator)
      Your Welcome
  • Adam
    Hey bro i have added this part of code in manifest and then when i run the app it’s shows an error “Manifest merger failed with multiple errors, see logs” like when i add this part of code then i face this problem so it’s mean by changing the value of allowbackup = “false” it shows an error right? so how do i resolve it?
    • anchit (Moderator)
      just add this line in your manifest file under application tag –>
  • Start a Project

      Message Sent!

      If you have more details or questions, you can reply to the received confirmation email.

      Back to Home