Disable or modify automated backups for your Android app

All Android versions starting from Android 6.0 (API level 23) back up your app’s data files and then automatically restore them when the app is reinstalled. 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 appropriate SDK files from full backup.

Instructions

We recommend disabling automated backups for your app. To do this, use the following in your AndroidManifest.xml file.

<manifest ... >
    ...
    <application android:allowBackup="true" ... >
        ...
    </application>
</manifest>

If your application must allow backups, be sure to exclude appropriate SDK files from full backup. To do this, create an .xml file with backup rules in the res/xml/ directory of your app, and then specify that .xml file in the AndroidManifest.xml file.

<application ...
 android:fullBackupContent="@xml/backup_rules">
</application>
<application ...
 android:dataExtractionRules="backup_rules.xml">
</application>

The following files must be excluded from backup:

<?xml version="1.0" encoding="utf-8"?>
<full-backup-content>
	<exclude domain="sharedpref" path="ACOUSTIC_MCE_SDK_DATA.xml"/>
	<exclude domain="database" path="mce3x.sqlite"/>
	<exclude domain="database" path="mce.attributes"/>
</full-backup-content>

Additionally, you must exclude all Campaign SDK plugins that your app uses.

  • Here is a rule for locations:
<?xml version="1.0" encoding="utf-8"?>
<full-backup-content>
	<exclude domain="database" path="locations.sqlite"/>
	<exclude domain="database" path="cognitive_location.sqlite"/>
</full-backup-content>
  • Here is a rule for inbox messages:
<?xml version="1.0" encoding="utf-8"?>
<full-backup-content>
	<exclude domain="database" path="messages.sqlite"/>
</full-backup-content>
  • Here is a rule for in-app messages:
<?xml version="1.0" encoding="utf-8"?>
<full-backup-content>
	<exclude domain="database" path="mceInappMessages.sqlite"/>
</full-backup-content>

If you have enabled the usePreferencesEncryption setting for Android in MceConfig.json, you must exclude EncryptedSharedPreferences from backup.

For more information about including and excluding files from backup, see Back up user data with Auto Backup in the Android Developer Help Center.