Java Code Examples for android.app.backup.BackupManager#dataChanged()
The following examples show how to use
android.app.backup.BackupManager#dataChanged() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DatabaseHelper.java From andOTP with MIT License | 6 votes |
public static boolean saveDatabase(Context context, ArrayList<Entry> entries, SecretKey encryptionKey) { if (encryptionKey == null) { Toast.makeText(context, R.string.toast_encryption_key_empty, Toast.LENGTH_LONG).show(); return false; } String jsonString = entriesToString(entries); try { synchronized (DatabaseHelper.DatabaseFileLock) { byte[] data = EncryptionHelper.encrypt(encryptionKey, jsonString.getBytes()); FileHelper.writeBytesToFile(new File(context.getFilesDir() + "/" + Constants.FILENAME_DATABASE), data); } } catch (Exception error) { error.printStackTrace(); return false; } BackupManager backupManager = new BackupManager(context); backupManager.dataChanged(); return true; }
Example 2
Source File: UserIdentifier.java From android-device-identification with Apache License 2.0 | 6 votes |
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; }
Example 3
Source File: LockSettingsService.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
private void setStringUnchecked(String key, int userId, String value) { Preconditions.checkArgument(userId != USER_FRP, "cannot store lock settings for FRP user"); mStorage.writeKeyValue(key, value, userId); if (ArrayUtils.contains(SETTINGS_TO_BACKUP, key)) { BackupManager.dataChanged("com.android.providers.settings"); } }
Example 4
Source File: SettingsActivity.java From andOTP with MIT License | 5 votes |
public void onSharedPreferenceChanged(SharedPreferences prefs, String key) { BackupManager backupManager = new BackupManager(this); backupManager.dataChanged(); if (key.equals(getString(R.string.settings_key_theme)) || key.equals(getString(R.string.settings_key_locale)) || key.equals(getString(R.string.settings_key_special_features)) || key.equals(getString(R.string.settings_key_backup_location))) { recreate(); } else if(key.equals(getString(R.string.settings_key_encryption))) { if (settings.getEncryption() != EncryptionType.PASSWORD) { if (settings.getAndroidBackupServiceEnabled()) { UIHelper.showGenericDialog(this, R.string.settings_dialog_title_android_sync, R.string.settings_dialog_msg_android_sync_disabled_encryption ); } settings.setAndroidBackupServiceEnabled(false); if (fragment.useAndroidSync != null) { fragment.useAndroidSync.setEnabled(false); fragment.useAndroidSync.setChecked(false); } } else { if (fragment.useAndroidSync != null) fragment.useAndroidSync.setEnabled(true); } } fragment.updateAutoBackup(); }
Example 5
Source File: SimpleBackupAgent.java From science-journal with Apache License 2.0 | 5 votes |
/** Schedule backups each time the preferences are modified. */ public static SharedPreferences.OnSharedPreferenceChangeListener registerOnSharedPreferencesChangeListener(Context applicationContext) { SharedPreferences.OnSharedPreferenceChangeListener listener = (sharedPreferences, s) -> BackupManager.dataChanged("com.google.android.apps.forscience.whistlepunk"); PreferenceManager.getDefaultSharedPreferences(applicationContext) .registerOnSharedPreferenceChangeListener(listener); return listener; }
Example 6
Source File: ChromeBackupWatcher.java From AndroidChromium with Apache License 2.0 | 5 votes |
private ChromeBackupWatcher() { Context context = ContextUtils.getApplicationContext(); if (context == null) return; mBackupManager = new BackupManager(context); // Watch the Java preferences that are backed up. SharedPreferences sharedPrefs = ContextUtils.getAppSharedPreferences(); // If we have never done a backup do one immediately. if (!sharedPrefs.getBoolean(FIRST_BACKUP_DONE, false)) { mBackupManager.dataChanged(); sharedPrefs.edit().putBoolean(FIRST_BACKUP_DONE, true).apply(); } sharedPrefs.registerOnSharedPreferenceChangeListener( new SharedPreferences.OnSharedPreferenceChangeListener() { @Override public void onSharedPreferenceChanged( SharedPreferences sharedPreferences, String key) { // Update the backup if the user id or any of the backed up Android // preferences change. if (key.equals(ChromeSigninController.SIGNED_IN_ACCOUNT_KEY)) { onBackupPrefsChanged(); return; } for (String pref : ChromeBackupAgent.BACKUP_ANDROID_BOOL_PREFS) { if (key.equals(pref)) { onBackupPrefsChanged(); return; } } } }); }
Example 7
Source File: MainActivity.java From android-device-identification with Apache License 2.0 | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); identityProvider = DeviceIdentityProvider.getInstance(this); // force backup for new device immediately if (identityProvider.isNewDevice()) { BackupManager backupManager = new BackupManager(this); backupManager.dataChanged(); } initView(); }
Example 8
Source File: MainActivity.java From android-device-identification with Apache License 2.0 | 5 votes |
@Override protected void onStop() { // allow backup authorized devices only if (identityProvider.isAuthorizedDevice()) { BackupManager backupManager = new BackupManager(this); backupManager.dataChanged(); } super.onStop(); }
Example 9
Source File: ChromeBackupWatcher.java From 365browser with Apache License 2.0 | 5 votes |
private ChromeBackupWatcher() { Context context = ContextUtils.getApplicationContext(); if (context == null) return; mBackupManager = new BackupManager(context); // Watch the Java preferences that are backed up. SharedPreferences sharedPrefs = ContextUtils.getAppSharedPreferences(); // If we have never done a backup do one immediately. if (!sharedPrefs.getBoolean(FIRST_BACKUP_DONE, false)) { mBackupManager.dataChanged(); sharedPrefs.edit().putBoolean(FIRST_BACKUP_DONE, true).apply(); } sharedPrefs.registerOnSharedPreferenceChangeListener( new SharedPreferences.OnSharedPreferenceChangeListener() { @Override public void onSharedPreferenceChanged( SharedPreferences sharedPreferences, String key) { // Update the backup if the user id or any of the backed up Android // preferences change. if (key.equals(ChromeSigninController.SIGNED_IN_ACCOUNT_KEY)) { onBackupPrefsChanged(); return; } for (String pref : ChromeBackupAgent.BACKUP_ANDROID_BOOL_PREFS) { if (key.equals(pref)) { onBackupPrefsChanged(); return; } } } }); }
Example 10
Source File: BackupUtils8.java From CSipSimple with GNU General Public License v3.0 | 4 votes |
@Override public void dataChanged() { BackupManager bmgr = new BackupManager(context); bmgr.dataChanged(); }
Example 11
Source File: SettingsFragment.java From Audinaut with GNU General Public License v3.0 | 4 votes |
private void scheduleBackup() { BackupManager backupManager = new BackupManager(context); backupManager.dataChanged(); }
Example 12
Source File: MyUtil.java From Clip-Stack with MIT License | 4 votes |
public static void requestBackup(Context context) { Log.d(MyUtil.PACKAGE_NAME, "requestBackup"); BackupManager backupManager = new BackupManager(context); backupManager.dataChanged(); }
Example 13
Source File: SyncStorageEngine.java From android_9.0.0_r45 with Apache License 2.0 | 2 votes |
/** * Let the BackupManager know that account sync settings have changed. This will trigger * {@link com.android.server.backup.SystemBackupAgent} to run. */ public void queueBackup() { BackupManager.dataChanged("android"); }