'how to specify to not allow any data backup with android:dataExtractionRules and
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.
Ive 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
Solution 1:[1]
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:
<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 "
AttributedataExtractionRulesis 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).
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Top-Master |
