I'm trying to backup/restore shared preferences of my app, I followed this step using Android Backup Service:
In Manifest.xml
in <application>
tag
<meta-data android:name="com.google.android.backup.api_key" android:value="My Key" />
added this class:
public class MyBackupAgent extends BackupAgentHelper {
// The name of the SharedPreferences file
static final String PREFS = "my_preferences";
@Override
public void onCreate() {
SharedPreferencesBackupHelper helper = new SharedPreferencesBackupHelper(this, PREFS);
addHelper(Utilities.SETTINGS_KEY, helper);
}
}
when set value to shared preference I do this:
BackupManager backupManager = new BackupManager(context);
backupManager.dataChanged();
But if I uninstall/reinstall app, changes doesn't apply...
<manifest ... > <application android:label="MyApplication" android:backupAgent="MyBackupAgent"> </application> </manifest>
– Esma