如何从 Android 6 自动备份中排除整个目录?
How to exclude an entire directory from Android 6 Auto Backup?
我想配置 Android 6 自动备份功能以排除整个目录中的所有文件(在 "files" 和 "external" 中),一些特定的扩展名也应该是排除在外。 . 和 *.tn-png 等通配符是否适用于路径值?
我无法明确定义所有文件,因为这些文件是在 运行 时间创建的。
android:fullBackupContent="@xml/mybackupscheme"
例如,mybackupscheme 是这样的:
<?xml version="1.0" encoding="utf-8"?>
<full-backup-content>
<exclude domain="file" path="device-links.xml"/>
<exclude domain="file" path="*.tn-png"/>
<exclude domain="file" path="links/*.*"/>
<exclude domain="external" path="external-links/*.*" />
</full-backup-content>
提前致谢,
path: Specifies a file or folder to include in or exclude from backup.
Note that: This attribute does not support wildcard or regex syntax.
所以不能使用通配符。
但是您可以使用 exclude
来排除整个目录
<exclude>
- Specifies a file or folder to exclude during backup.
如果您的文件结构非常复杂,您可以实现自己的 BackupAgent
并覆盖 onFullBackup
方法。
You can't easily express the set of files you want to backup with
XML rules. In these rare cases, you can implement a BackupAgent that
overrides onFullBackup(FullBackupDataOutput) to store what you want.
To retain the system's default implementation, call the corresponding
method on the superclass with super.onFullBackup().
我想配置 Android 6 自动备份功能以排除整个目录中的所有文件(在 "files" 和 "external" 中),一些特定的扩展名也应该是排除在外。 . 和 *.tn-png 等通配符是否适用于路径值? 我无法明确定义所有文件,因为这些文件是在 运行 时间创建的。
android:fullBackupContent="@xml/mybackupscheme"
例如,mybackupscheme 是这样的:
<?xml version="1.0" encoding="utf-8"?>
<full-backup-content>
<exclude domain="file" path="device-links.xml"/>
<exclude domain="file" path="*.tn-png"/>
<exclude domain="file" path="links/*.*"/>
<exclude domain="external" path="external-links/*.*" />
</full-backup-content>
提前致谢,
path: Specifies a file or folder to include in or exclude from backup. Note that: This attribute does not support wildcard or regex syntax.
所以不能使用通配符。
但是您可以使用 exclude
来排除整个目录
<exclude>
- Specifies a file or folder to exclude during backup.
如果您的文件结构非常复杂,您可以实现自己的 BackupAgent
并覆盖 onFullBackup
方法。
You can't easily express the set of files you want to backup with XML rules. In these rare cases, you can implement a BackupAgent that overrides onFullBackup(FullBackupDataOutput) to store what you want. To retain the system's default implementation, call the corresponding method on the superclass with super.onFullBackup().