// Go Back to Title Screen @Override public void onBackPressed() { // Get New Values int theme = themeSpinner.getSelectedItemPosition(); int controls = controlsSpinner.getSelectedItemPosition(); int view = viewSpinner.getSelectedItemPosition(); int speed = speedSpinner.getSelectedItemPosition(); // Save in Settings // Speed Setting is Stored in a Different File Because It Should Not Be Synced Across Devices userPreferencesEditor = userPreferences.edit(); userPreferencesEditor.putInt("theme", theme); userPreferencesEditor.putInt("controls", controls); userPreferencesEditor.putInt("view", view); speedSettingEditor = speedSetting.edit(); speedSettingEditor.putInt("speed", speed); userPreferencesEditor.commit(); speedSettingEditor.commit(); // Call for Backup BackupManager backupManager = new BackupManager(this); backupManager.dataChanged(); // Go Home & Close Options Screen Intent intent = new Intent(this, TitleScreen.class); startActivity(intent); this.finish(); }
public static String getUserID(Context context) { if (uniqueID == null) { SharedPreferences sharedPrefs = context.getSharedPreferences(SimpleBackupAgent.PREFS, Context.MODE_PRIVATE); uniqueID = sharedPrefs.getString(PREF_UNIQUE_ID, null); if (uniqueID == null) { uniqueID = UUID.randomUUID().toString(); SharedPreferences.Editor editor = sharedPrefs.edit(); editor.putString(PREF_UNIQUE_ID, uniqueID); editor.commit(); // backup the changes BackupManager mBackupManager = new BackupManager(context); mBackupManager.dataChanged(); } } return uniqueID; }
@Override public void dataChanged() { // Copy Database to temp location try { FileUtils.copyFile( new FileInputStream(context.getDatabasePath("tac.db")), context.openFileOutput(BACKUP_LOCATION, Context.MODE_PRIVATE)); } catch (final Exception e) { Log.e(TAG, "Could not copy database to backup location", e); } super.dataChanged(); } // dataChanged
@Override public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) { Activity a = getActivity(); if (key.equals(KEY_ALERTS)) { updateChildPreferences(); if (a != null) { Intent intent = new Intent(); intent.setClass(a, AlertReceiver.class); if (mAlert.isChecked()) { intent.setAction(AlertReceiver.ACTION_DISMISS_OLD_REMINDERS); } else { intent.setAction(AlertReceiver.EVENT_REMINDER_APP_ACTION); } a.sendBroadcast(intent); } } if (a != null) { BackupManager.dataChanged(a.getPackageName()); } }
/** * Notify the backup manager that out database is dirty. * * <p>This does not force an immediate backup. * * @param context application context */ public static void dataChanged(Context context) { if (sBackupManager == null) { sBackupManager = new BackupManager(context); } sBackupManager.dataChanged(); }
public static void requestBackup() { BackupManager.dataChanged(AppCore.context().getPackageName()); }
public void requestBackup() { BackupManager bm = new BackupManager(this); bm.dataChanged(); }