androidgoogle-cloud-messagingandroid-6.0-marshmallowandroid-backup-service

Android 23+ - Exclude GCM Registration ID from backup


I have an app which uses Azure to send Push notifications. Azure in turn, uses GCM to send to Android devices.

I'm noticing that I have a warning in my AndroidManifest.xml stating

On SDK version 23 and up, your app data will be automatically backed up, and restored on app install. Your GCM regid will not work across restores, so you must ensure that it is excluded from the back-up set. Use the attribute android:fullBackupContent to specify an @xml resource which configures which files to backup.

I have following the instructions here https://developer.android.com/training/backup/autosyncapi.html?hl=in#configuring

however I am stumped as to how to exclude the GCM regID from the backup? Here is my current setup.

Manifest

<application
        android:allowBackup="true"
        android:fullBackupContent="@xml/backup_scheme"
        ........

res/xml/backup_scheme.xml

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

What do I put as path? Am I supposed to have a physical file somewhere I exclude?

UPDATE

So I think I figured it out. In my RegistrationIntentService.java file, I store the users registrationID in the shared preferences under the string "registrationID". So I'm assuming I use the following...

<exclude domain="sharedpref" path="registrationID"/>

right?


Solution

  • So I figured it out. In my RegistrationIntentService.java file, I store the users registrationID in the shared preferences under the string "registrationID". So use the following in the backup_scheme.xml file...

    <exclude domain="sharedpref" path="registrationID"/>