My current Android application targets 12 and higher.
I do not want to allow backup of any type and currently have these manifest settings:
android:allowBackup="false"
android:fullBackupContent="false"
However the android:allowBackup="false"
setting gives the following warning now:
The attribute android:allowBackup is deprecated from Android 12 and higher and may be removed in future versions. Consider adding the attribute android:dataExtractionRules specifying an @xml resource which configures cloud backups and device transfers on Android 12 and higher.
I've looked at the examples for android:dataExtractionRules
xml and none of them show how to configure the equivalent of allowBackup="false"
.
What am I missing?
Is it possible to achieve allowBackup="false"
with the use of android:dataExtractionRules
xml?
Add dataExtractionRules
attribute to your AndroidManifest.xml file with a reference to data_extraction_rules.xml file:
<application
android:allowBackup="false"
android:fullBackupContent="false"
android:dataExtractionRules="@xml/data_extraction_rules"
...>
Then, exclude all possible domains for cloud backups and d2d transfers, update or create a file app/src/main/res/xml/data_extraction_rules.xml:
<?xml version="1.0" encoding="utf-8"?>
<data-extraction-rules>
<cloud-backup>
<exclude domain="root" />
<exclude domain="file" />
<exclude domain="database" />
<exclude domain="sharedpref" />
<exclude domain="external" />
</cloud-backup>
<device-transfer>
<exclude domain="root" />
<exclude domain="file" />
<exclude domain="database" />
<exclude domain="sharedpref" />
<exclude domain="external" />
</device-transfer>
</data-extraction-rules>
The dataExtractionRules
attribute is available for API 31 (Android 12) and higher. Keep allowBackup
and fullBackupContent
attributes for Android versions before API 31.
Note to maybe silence "
Attribute dataExtractionRules is only used in API level 31 and higher (current min is 19)
" warning, withtools:targetApi="s"
attribute as well (because older platforms simply ignore manifest-attributes they don't support, and the warning is useless).