I wonder if it's possible to backup and restore a DataStore via the backup feature on Android.
Let's say I have some AppDataStore class which provides a logic to keep some user-related preferences via the jetpack DataStore:
private val Context.dataStore: DataStore<Preferences> by preferencesDataStore(name = "settings")
I use the dataStore object above to write and read some primitive data and everything works well. The file is created and stays alive. However, I can't find a way to make backup logic work (actually backup logic worked flawlessly with the shared prefs previously).
To have backup working I have these changes in my manifest file:
<application
...
android:fullBackupContent="@xml/backup_rules"
android:allowBackup="true">
And here is the backup_rules.xml:
<?xml version="1.0" encoding="utf-8"?>
<full-backup-content>
<include
domain="file"
path="datastore/settings.preferences_pb" />
</full-backup-content>
I tried different paths, even following the exact folders structure, but still nothing.
Has anyone faced this issue before? Any ideas maybe?