diff options
| author | 2014-01-13 04:32:19 -0800 | |
|---|---|---|
| committer | 2014-01-13 04:32:19 -0800 | |
| commit | bc2a449a615b30efb81a1a0082a1bb0db515d0f5 (patch) | |
| tree | 57628b406c56ec0edad84110b519c3463aad87e9 | |
| parent | 739ae9b3b77458b4c77f799cba56dc68d65ab424 (diff) | |
| parent | cb4d3ec1ea446fc9ce51514cbf5b16da0ec0fa0f (diff) | |
am cb4d3ec1: Merge "Fix preference puts with "null" values."
* commit 'cb4d3ec1ea446fc9ce51514cbf5b16da0ec0fa0f':
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)) { |