Merge pull request #2454 from twain47/key-value-backups

Use google key/value backup agent for settings and objectives
This commit is contained in:
Milos Kozak 2020-03-20 18:36:19 +01:00 committed by GitHub
commit 7db4481db9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 32 additions and 1 deletions

View file

@ -38,7 +38,14 @@
android:roundIcon="${appIconRound}"
android:supportsRtl="true"
android:theme="@style/AppTheme.Launcher"
android:fullBackupContent="true">
android:fullBackupOnly="false"
android:backupAgent=".utils.SPBackupAgent"
android:restoreAnyVersion="true">
<meta-data
android:name="com.google.android.backup.api_key"
android:value="AEdPqrEAAAAI3JiApyMrbP2QFzZ2fYfCPsgjkRp53Dm2S1-zPQ" />
<meta-data
android:name="com.google.android.gms.car.application"
android:resource="@xml/automotive_app_desc" />

View file

@ -0,0 +1,24 @@
package info.nightscout.androidaps.utils;
import android.app.backup.BackupAgentHelper;
import android.app.backup.SharedPreferencesBackupHelper;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
import info.nightscout.androidaps.MainApp;
public class SPBackupAgent extends BackupAgentHelper {
// API 24
//static final String PREFS = PreferenceManager.getDefaultSharedPreferencesName(MainApp.instance().getApplicationContext());
static final String PREFS = MainApp.instance().getApplicationContext().getPackageName() + "_preferences";
static final String PREFS_BACKUP_KEY = "SP";
@Override
public void onCreate() {
SharedPreferencesBackupHelper helper =
new SharedPreferencesBackupHelper(this, PREFS);
addHelper(PREFS_BACKUP_KEY, helper);
}
}