How to disable or modify automated backups for your application (Android)

Overview

Android versions of 6.0 and above (API 23) will back up your app’s data files and then automatically restore them when the app is reinstalled. This can cause unexpected behavior if you are using invalidateExistingUser: true, if the backup is outdated, or if you are testing

To limit unexpected behavior from your application when invalidateExistingUser: true, if the backup is outdated, or if you are testing, you should either disable automated backups or exclude the appropriate SDK files from full backup.

Step-by-step

1. To disable automated backups for your application (recommended)

Use

<application android:allowBackup="false" ...

in your AndroidManifest.xml file.

2. If your application must allow backups for other purposes, be sure to exclude the appropriate SDK files from full backup.

You do this by adding an .xml file with backup rules to your app, and then specifying that .xml file in the AndroidManifest.xml file:

<application android:fullBackupContent="@xml/my_backup_rules"...

The following files must be excluded by adding backup rules for them:

<exclude domain="sharedpref" path="IBM_MCE_SDK_DATA.xml"/>
<exclude domain="database" path="mce3x.sqlite"/>
<exclude domain="database" path="mce.attributes"/>

3. If you use locations, you must ALSO exclude:

Be sure to include step 2 with these rules as well.

<exclude domain="database" path="locations.sqlite"/>
<exclude domain="database" path="cognitive_location.sqlite"/>

4. If you use inbox messages, you must ALSO exclude:

Be sure to include step 2 with this rule as well.

<exclude domain="database" path="messages.sqlite"/>

5. If you use in-app messages, you must ALSO exclude:

Be sure to include step 2 with this rule as well.

<exclude domain="database" path="mceInappMessages.sqlite"/>

For more information about including and excluding files from backup, see Android's information regarding files that are backed up here.


Did this page help you?