How to prevent auto-backup of an Android app?

<application ...
    android:allowBackup="false"
    android:fullBackupContent="false"
    tools:replace="android:allowBackup"
</application>

I had this same problem and really had to scratch my head because Google has not highlighted a subtle change in App backup feature.Starting from API level 23, all app data will be automatically backed up in Google drive. This data would be restored back when the app is installed back. So the data does not go away even when you uninstall the app.

Mostly your app manifest would have an entry like this -

android:allowBackup="true"

Change the value to false or else follow the below link and configure an xml letting the backup service know what to backup and what not to.

https://developer.android.com/guide/topics/data/autobackup.html


Since Android 6.0 (v 23) onward, Android introduced a new feature called Auto-backup for apps . What this does is, it performs a backup of certain files of an application to a user's Google drive. The list of files it updates include:

  • Shared preferences files
  • Files in the directory returned by getFilesDir()
  • Files in the directory returned by getDatabasePath(String)
  • Files in directories created with getDir(String, int)
  • Files on external storage in the directory returned by getExternalFilesDir(String)

Now this line in the manifest.xml is responsible for it :

android:allowBackup="true"

If you prefer to disable the backup, should you choose to set the value to false.

Furthermore, the data backed up is in a 24 hour interval and Android uses the JobScheduler API for this purpose, so which means a user has no control over the process of data being transferred.

Also, the space for auto-backups is limited to 25MB , and which is not counted against the user's space quota.

Also, you can set to <include> and <exclude> certain type of data being uploaded, for instance you may not need to save a user confidential data, so it is flexible for that as well, more info on that is available at : Android Auto Backup for Apps (100 Days of Google Dev)


Simply change

android:allowBackup="true"

to

android:allowBackup="false"

And if you are using any dependency, to override this property use

tools:replace="android:allowBackup"
android:allowBackup="false"