When we don't want to maintain SharedPreferences or any backup file, we can just set android:allowBackup="false" in AndroidManifest.xml.
But android:allowBackup="false" is deprecated in Android12. Even though it's deprecated, we can still keep using it just for the cloud-based backup. for example, if we're using SharedPreferences, after deleting our app and re-installing it, the SharedPreferences are gone.
You can find the information from here.
So, What i want to know is about D2D. In Android12, The android system automatically send files from old device to new device(D2D). I want to stop the system from sending files(like SharedPreferences) automactically by default. So, I have to make dataExtractionRules which files include or not.
What i want to do is to exclude all files. it means that i can just transfer the app to new device but there are no data or cache like i just downloaded a new app. So, How can i write dataExtractionRules to acheive it?
please check the following code what i did.
data_exctration_rules.xml
<?xml version="1.0" encoding="utf-8"?>
<data-extraction-rules>
<!-- <cloud-backup> I don't write cloud-backups in here
because i can still use android:allowBackup="false" </cloud-backup> -->
<device-transfer>
<exclude domain="root" path="where?" />
<exclude domain="file" path="where?" />
<exclude domain="database" path="where?" />
<exclude domain="sharedpref" path="com.google.android.gms.appid.xml" />
<exclude domain="sharedpref" path="user_pref.xml" />
<!-- <exclude domain="external" path="where?" /> -->
</device-transfer>
</data-extraction-rules>
Q1. Can i use several <exclude domain="sharedpref">? because i have 4 files of SharedPrefereces.
Q2. How exactly should I write down the path? ex) "data/data/com.myapp/sharedpref/user_pref.xml" or just "user_pref.xml"
Q3. What does "<exclude domain="root" path="" />" mean?
does root mean my app? if it is, Don't I need to write another file(like file, database, sharedpref, external etc)?
You should read docs.
The brief answers about your questions.
Yes, you can. You should indicate several declaration or just one with
./pathattribute(all files in this directory).You can check your shared preferences xml file name in device file explorer of Android Studio tool.
Just
user_pref.xmlthedomainautomatically generate a path for the matched filename.I think, you need just
rootdomain and./path for ignoring all file backup.But I recommended like that