Exclude MoEngage Storage File from Auto-Backup
warning

Critical

Mandatory integration step to prevent data corruption.

Auto backup service of Android periodically backs up the Shared Preference file, Database files, and so on.

For more information, refer to Auto Backup.

The backup results in MoEngage SDK identifiers to be backed up and restored after re-install. The restoration of the identifier results in your data being corrupted and the user not being reachable using push notifications.

To ensure data is not corrupted after a backup is restored, opt-out of MoEngage SDK storage files.

Add a backup descriptor in the application tag of the Manifest file.

The backup descriptor should be assigned to fullBackupContent attribute of the application tag.

AndroidManifest.xml
<application
...
android:fullBackupContent="@xml/backup_descriptor">
</application>

Exclude MoEngage Files in the descriptor file.

Exclude the following database file and shared preference file in the descriptor to ensure these files are not backed up.

XML
<?xml version="1.0" encoding="utf-8"?>
<full-backup-content>
<exclude domain="database" path="MOEInteractions"/>

<exclude domain="sharedpref" path="pref_moe.xml"/>
</full-backup-content>

 

If you only want to exclude files only from MoEngage SDK instead of creating a new file you can directly add the backup descriptor file provided by the SDK to the manifest file as shown below.

AndroidManifest.xml
<application
...
android:fullBackupContent="@xml/com_moengage_backup_descriptor">
</application>

For applications with targetSdkVersion 31 or above exclusion has to be done in the new format as well.

Exclusion for API level 31 or above

Add manifest flag

Declare the new configuration file in the manifest file as shown below.

XML
<application
    ...
    <!-- The below attribute is ignored. -->
    android:fullBackupContent="@xml/old_config.xml"
    <!-- You can point to your new configuration using the new
         dataExtractionRules attribute . -->
    android:dataExtractionRules="@xml/new_config.xml"
    ...>
</application>

Exclude MoEngage Files in the configuration file.

You can exclude MoEngage files from the configuration as shown below

XML
<data-extraction-rules>
  <cloud-backup>
    ...
    <exclude domain="database" path="MOEInteractions"/>
    <exclude domain="sharedpref" path="pref_moe.xml"/> 
  </cloud-backup>
  <device-transfer>
    ...
    <exclude domain="database" path="MOEInteractions"/>
    <exclude domain="sharedpref" path="pref_moe.xml"/>
    ...
  </device-transfer>
</data-extraction-rules>

 

If you only want to exclude files only from MoEngage SDK, instead of creating a new file, you can directly add the backup descriptor file and data extraction rules file provided by the SDK to the manifest file, as shown below.

AndroidManifest.xml
<application
...
android:fullBackupContent="@xml/com_moengage_backup_descriptor"
android:dataExtractionRules="@xml/com_moengage_data_extraction_rules"
>
</application>

 

Previous

Next

Was this article helpful?
1 out of 1 found this helpful

How can we improve this article?