diff options
| author | 2014-01-13 12:29:41 +0000 | |
|---|---|---|
| committer | 2014-01-13 12:29:41 +0000 | |
| commit | cb4d3ec1ea446fc9ce51514cbf5b16da0ec0fa0f (patch) | |
| tree | 565b7dfd371971c80337630c9291bbbf32c9df34 | |
| parent | 868173a53f0d1059408b049f30af3402d5b0de64 (diff) | |
| parent | c6f429007c2c402be71f69693cb1d2e6a1c8d0cf (diff) | |
Merge "Fix preference puts with "null" values."
| -rw-r--r-- | core/java/android/app/SharedPreferencesImpl.java | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/core/java/android/app/SharedPreferencesImpl.java b/core/java/android/app/SharedPreferencesImpl.java index 86fd7b977b1a..a292ecbf4df0 100644 --- a/core/java/android/app/SharedPreferencesImpl.java +++ b/core/java/android/app/SharedPreferencesImpl.java @@ -421,13 +421,15 @@ final class SharedPreferencesImpl implements SharedPreferences { for (Map.Entry<String, Object> e : mModified.entrySet()) { String k = e.getKey(); Object v = e.getValue(); - if (v == this) { // magic value for a removal mutation + // "this" is the magic value for a removal mutation. In addition, + // setting a value to "null" for a given key is specified to be + // equivalent to calling remove on that key. + if (v == this || v == null) { if (!mMap.containsKey(k)) { continue; } mMap.remove(k); } else { - boolean isSame = false; if (mMap.containsKey(k)) { Object existingValue = mMap.get(k); if (existingValue != null && existingValue.equals(v)) { |