SharedPreferences commit -> apply

Change-Id: Icdca00268a8b5ea274c91366867172ee7e3841d4
This commit is contained in:
Brad Fitzpatrick 2010-11-01 08:51:26 -07:00
parent 34e6205d44
commit bd29c30903
3 changed files with 12 additions and 12 deletions

View File

@ -295,7 +295,7 @@ public class Account {
// also delete any deprecated fields
editor.remove(mUuid + ".transportUri");
editor.commit();
editor.apply();
}
public void save(Preferences preferences) {
@ -329,7 +329,7 @@ public class Account {
accountUuids += (accountUuids.length() != 0 ? "," : "") + mUuid;
SharedPreferences.Editor editor = preferences.mSharedPreferences.edit();
editor.putString("accountUuids", accountUuids);
editor.commit();
editor.apply();
}
SharedPreferences.Editor editor = preferences.mSharedPreferences.edit();
@ -365,7 +365,7 @@ public class Account {
// also delete any deprecated fields
editor.remove(mUuid + ".transportUri");
editor.commit();
editor.apply();
}
@Override

View File

@ -136,11 +136,11 @@ public class Preferences {
}
public void setDefaultAccount(Account account) {
mSharedPreferences.edit().putString(DEFAULT_ACCOUNT_UUID, account.getUuid()).commit();
mSharedPreferences.edit().putString(DEFAULT_ACCOUNT_UUID, account.getUuid()).apply();
}
public void setEnableDebugLogging(boolean value) {
mSharedPreferences.edit().putBoolean(ENABLE_DEBUG_LOGGING, value).commit();
mSharedPreferences.edit().putBoolean(ENABLE_DEBUG_LOGGING, value).apply();
}
public boolean getEnableDebugLogging() {
@ -148,7 +148,7 @@ public class Preferences {
}
public void setEnableExchangeLogging(boolean value) {
mSharedPreferences.edit().putBoolean(ENABLE_EXCHANGE_LOGGING, value).commit();
mSharedPreferences.edit().putBoolean(ENABLE_EXCHANGE_LOGGING, value).apply();
}
public boolean getEnableExchangeLogging() {
@ -156,7 +156,7 @@ public class Preferences {
}
public void setEnableExchangeFileLogging(boolean value) {
mSharedPreferences.edit().putBoolean(ENABLE_EXCHANGE_FILE_LOGGING, value).commit();
mSharedPreferences.edit().putBoolean(ENABLE_EXCHANGE_FILE_LOGGING, value).apply();
}
public boolean getEnableExchangeFileLogging() {
@ -172,7 +172,7 @@ public class Preferences {
String result = mSharedPreferences.getString(DEVICE_UID, null);
if (result == null) {
result = UUID.randomUUID().toString();
mSharedPreferences.edit().putString(DEVICE_UID, result).commit();
mSharedPreferences.edit().putString(DEVICE_UID, result).apply();
}
return result;
}
@ -182,7 +182,7 @@ public class Preferences {
}
public void setOneTimeInitializationProgress(int progress) {
mSharedPreferences.edit().putInt(ONE_TIME_INITIALIZATION_PROGRESS, progress).commit();
mSharedPreferences.edit().putInt(ONE_TIME_INITIALIZATION_PROGRESS, progress).apply();
}
public int getAutoAdvanceDirection() {
@ -190,14 +190,14 @@ public class Preferences {
}
public void setAutoAdvanceDirection(int direction) {
mSharedPreferences.edit().putInt(AUTO_ADVANCE_DIRECTION, direction).commit();
mSharedPreferences.edit().putInt(AUTO_ADVANCE_DIRECTION, direction).apply();
}
public void save() {
}
public void clear() {
mSharedPreferences.edit().clear().commit();
mSharedPreferences.edit().clear().apply();
}
public void dump() {

View File

@ -451,7 +451,7 @@ public class AccountSettingsFragment extends PreferenceFragment {
// The following two lines act as a workaround for the RingtonePreference
// which does not let us set/get the value programmatically
SharedPreferences prefs = mAccountRingtone.getPreferenceManager().getSharedPreferences();
prefs.edit().putString(PREFERENCE_RINGTONE, mAccount.getRingtone()).commit();
prefs.edit().putString(PREFERENCE_RINGTONE, mAccount.getRingtone()).apply();
mAccountVibrateWhen = (ListPreference) findPreference(PREFERENCE_VIBRATE_WHEN);
boolean flagsVibrate = 0 != (mAccount.getFlags() & Account.FLAGS_VIBRATE_ALWAYS);