0

I have the following settings

AndroidManifest.xml

<application
    android:fullBackupOnly="true"
    android:allowBackup="true"

    android:fullBackupContent="@xml/my_backup_rules"
    android:dataExtractionRules="@xml/my_backup_rules_v31"

my_backup_rules.xml

<?xml version="1.0" encoding="utf-8"?>
<full-backup-content>
    <include domain="file" path="." />
    <include domain="database" path="." />
    <include domain="external" path="." />
    <include domain="root" path="." />

    <include domain="sharedpref" path="." />
    <exclude domain="sharedpref" path="admob.xml" />
    <exclude domain="sharedpref" path="androidx.work.util.id.xml" />
    <exclude domain="sharedpref" path="com.google.android.gms.appid.xml" />
    <exclude domain="sharedpref" path="com.google.android.gms.analytics.prefs.xml" />
    <exclude domain="sharedpref" path="com.google.android.gms.appid.xml" />
    <exclude domain="sharedpref" path="com.google.android.gms.measurement.prefs.xml" />
</full-backup-content>

my_backup_rules_v31.xml

<?xml version="1.0" encoding="utf-8"?>
<data-extraction-rules>
    <cloud-backup disableIfNoEncryptionCapabilities="false">
        <include domain="file" path="." />
        <include domain="database" path="." />
        <include domain="external" path="." />
        <include domain="root" path="." />

        <include domain="sharedpref" path="." />
        <exclude domain="sharedpref" path="admob.xml" />
        <exclude domain="sharedpref" path="androidx.work.util.id.xml" />
        <exclude domain="sharedpref" path="com.google.android.gms.appid.xml" />
        <exclude domain="sharedpref" path="com.google.android.gms.analytics.prefs.xml" />
        <exclude domain="sharedpref" path="com.google.android.gms.appid.xml" />
        <exclude domain="sharedpref" path="com.google.android.gms.measurement.prefs.xml" />
    </cloud-backup>
</data-extraction-rules>

I use the following methodology to perform testing


  1. Upload app into phone via Android Studio.
  2. Execute the following code in Android Studio's terminal adb shell bmgr backupnow com.xxx.yyy
  3. You should able to observe backup progress log
  4. Uninstall the app from device.
  5. Upload app into phone via Android Studio. We should observe the old data is still there.

However, if I build the app, release it via Google Play.

  1. Install app from Google Play.
  2. Trigger backup explicitly in System/ Backup
  3. Go to Drive app's navigation drawer under Settings > Backup, confirm the app backup is there.
  4. Uninstall app.
  5. Reinstall app from Google Play. Expecting data will be restored automatically
  6. However, when I launch the app, the old data is not there.

May I know, what can possible went wrong? Note, previously, the backup mechanism works fine. It only break, after we migrate to API 31.

Thanks.

Cheok Yan Cheng
  • 47,586
  • 132
  • 466
  • 875

0 Answers0