Backup rules - infobip/mobile-messaging-sdk-android GitHub Wiki

SDK version 14.15.0 and later

Starting from version 14.15.0, the SDK no longer defines its own backup rules or sets android:allowBackup="false" in the manifest. Android's default backup behavior applies, meaning all app data — including SDK data — is backed up automatically.

The SDK handles backup and restore gracefully. After a restore, it detects that the device registration has been lost, clears device-bound state (push token, carrier info), and preserves user-level data (user ID, custom attributes, push settings). This preserved data is automatically re-synced with the backend on the next registration cycle.

Custom backup rules

If your app defines its own backup rules (via android:fullBackupContent or android:dataExtractionRules), the SDK's data will follow those rules.

Including SDK data in your backup rules means user data and message history will survive a backup/restore cycle. After restore, the SDK will detect the lost registration, preserve the user data, and re-sync it with the backend.

Excluding SDK data means the SDK starts fresh after a restore — no user data, no message history. The SDK treats this as a new installation and registers from scratch. No crash or error will occur.

If your app does not define any backup rules, Android defaults apply and all data is backed up.

Android 11 and lower

At the application level of your AndroidManifest.xml file add:

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

Then create your_backup_rules resource file in the /res/xml folder as following:

<full-backup-content>
    <include domain=["file" | "database" | "sharedpref" | "external" |
    "root" | "device_file" | "device_database" |
    "device_sharedpref" | "device_root" ] path="string"
    requireFlags=["clientSideEncryption" | "deviceToDeviceTransfer"] />
    <exclude domain=["file" | "database" | "sharedpref" | "external" |
    "root" | "device_file" | "device_database" |
    "device_sharedpref" | "device_root" ] path="string" />
</full-backup-content>

Android 12 or higher

At the application level of your AndroidManifest.xml file add:

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

In the res/xml folder, create the resource file data_backup_rules.xml as following:

<data-extraction-rules>
    <cloud-backup [disableIfNoEncryptionCapabilities="true|false"]>
        ...
        <include domain=["file" | "database" | "sharedpref" | "external" |
        "root" | "device_file" | "device_database" |
        "device_sharedpref" | "device_root" ] path="string"/>
        ...
        <exclude domain=["file" | "database" | "sharedpref" | "external" |
        "root" | "device_file" | "device_database" |
        "device_sharedpref" | "device_root" ] path="string"/>
        ...
    </cloud-backup>
    <device-transfer>
        ...
        <include domain=["file" | "database" | "sharedpref" | "external" |
        "root" | "device_file" | "device_database" |
        "device_sharedpref" | "device_root" ] path="string"/>
        ...
        <exclude domain=["file" | "database" | "sharedpref" | "external" |
        "root" | "device_file" | "device_database" |
        "device_sharedpref" | "device_root" ] path="string"/>
        ...
    </device-transfer>
</data-extraction-rules>

If there are no rules for a particular backup mode, such as if the <device-transfer> section is missing, that mode is fully enabled for all content except for no-backup and cache directories, as described in the documentation.

For additional information on backup and restore, please follow official documentation, along with testing guidelines.

SDK versions 12.0.0 to 14.14.x

In these versions, the SDK shipped its own backup rules and set android:allowBackup="false" in the manifest. Only SDK-related shared preferences and the database were backed up to the cloud, and device-to-device transfer was disabled. These rules could be overridden at the application level using the XML formats described above.