private void copyPrefs(String srcPrefsName, String destPrefsName) { Tool.setTimer(); SharedPreferences srcPrefs = AppCore.context().getSharedPreferences(srcPrefsName, 0); SharedPreferences destPrefs = AppCore.context().getSharedPreferences(destPrefsName, 0); if (D) Wow.d( TAG, "copyPrefs", "BACKUP copy Prefs..." + srcPrefs.getAll().size() + " from " + srcPrefsName + " to " + destPrefsName); SharedPreferences.Editor editor = destPrefs.edit(); for (Map.Entry<String, ?> entry : srcPrefs.getAll().entrySet()) { String key = entry.getKey(); Object val = entry.getValue(); // if (D) Wow.d("BACKUP", ">>>APPCORE BACKUP restore > key = "+key+", val // = "+val); if (val == null) continue; else if (val instanceof Float) editor.putFloat(key, (Float) val); else if (val instanceof Integer) editor.putInt(key, (Integer) val); else if (val instanceof Long) editor.putLong(key, (Long) val); else if (val instanceof Boolean) editor.putBoolean(key, (Boolean) val); else editor.putString(key, val.toString()); } editor.commit(); // if (D) Wow.d("BACKUP", ">>>APPCORE BACKUP copy // Prefs.. time = " + Tool.getTimer(true)); }
public static void requestBackup() { BackupManager.dataChanged(AppCore.context().getPackageName()); }