From bd29c3090305ce415fb29ba7af339a1359c746d3 Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Mon, 1 Nov 2010 08:51:26 -0700 Subject: [PATCH] SharedPreferences commit -> apply Change-Id: Icdca00268a8b5ea274c91366867172ee7e3841d4 --- src/com/android/email/Account.java | 6 +++--- src/com/android/email/Preferences.java | 16 ++++++++-------- .../activity/setup/AccountSettingsFragment.java | 2 +- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/com/android/email/Account.java b/src/com/android/email/Account.java index 7e1ad4db9..76a81255b 100644 --- a/src/com/android/email/Account.java +++ b/src/com/android/email/Account.java @@ -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 diff --git a/src/com/android/email/Preferences.java b/src/com/android/email/Preferences.java index eb6af8231..df519dee4 100644 --- a/src/com/android/email/Preferences.java +++ b/src/com/android/email/Preferences.java @@ -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() { diff --git a/src/com/android/email/activity/setup/AccountSettingsFragment.java b/src/com/android/email/activity/setup/AccountSettingsFragment.java index 0bae736ed..615333be2 100644 --- a/src/com/android/email/activity/setup/AccountSettingsFragment.java +++ b/src/com/android/email/activity/setup/AccountSettingsFragment.java @@ -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);