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
- Upload app into phone via Android Studio.
- Execute the following code in Android Studio's terminal
adb shell bmgr backupnow com.xxx.yyy
- You should able to observe backup progress log
- Uninstall the app from device.
- 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.
- Install app from Google Play.
- Trigger backup explicitly in System/ Backup
- Go to Drive app's navigation drawer under Settings > Backup, confirm the app backup is there.
- Uninstall app.
- Reinstall app from Google Play. Expecting data will be restored automatically
- 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.