【问题标题】:dataExtractionRules in Android12Android12中的数据提取规则
【发布时间】:2022-09-26 14:23:45
【问题描述】:

当我们不想维护SharedPreferences或任何备份文件时,我们可以在AndroidManifest.xml中设置android:allowBackup=\"false\"
android:allowBackup=\"false\" 在 Android12 中已弃用。即使认为它已被弃用,我们仍然可以继续将它仅用于cloud-based backup。例如,如果我们使用SharedPreferences,在删除我们的应用程序并重新安装后,SharedPreferences 就消失了。 您可以从here 找到信息。

所以,我想知道的是关于D2D。在 Android12 中,android 系统自动将文件从旧设备发送到新设备(D2D)。我想阻止系统默认自动发送文件(如SharedPreferences)。所以,我必须让dataExtractionRules 包含或不包含哪些文件。

我想要做的是排除所有文件。这意味着我可以将应用程序转移到新设备,但没有数据或缓存,就像我刚刚下载了一个新应用程序一样。那么,我该如何写dataExtractionRules 来实现呢?

请检查以下代码我做了什么。

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。我可以使用几个&lt;exclude domain=\"sharedpref\"&gt; 吗?因为我有 4 个 SharedPrefereces 文件。

Q2。我应该如何准确地写下路径? 例如)\"data/data/com.myapp/sharedpref/user_pref.xml\" 或只是 \"user_pref.xml\"

Q3。 \"&lt;exclude domain=\"root\" path=\"\" /&gt;\" 是什么意思? root 是指我的应用程序吗?如果是,我不需要写另一个文件(如文件、数据库、sharedpref、外部等)吗?

    标签: android android-manifest android-12 android-backup-service


    【解决方案1】:

    https://youtu.be/bg2drEhz1_s 这是您问题的解决方案。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-12-22
      • 2016-07-28
      • 2010-10-20
      • 2016-11-30
      • 2019-06-14
      • 1970-01-01
      • 1970-01-01
      • 2019-09-02
      相关资源
      最近更新 更多