summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDave Santoro <dsantoro@google.com>2011-09-21 14:47:59 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2011-09-21 14:47:59 -0700
commitae94a710dbc0ea239277c25986e39ba53904c5fc (patch)
tree0ff2a0890e8953f136f6ddbdc8fbcbc1533620d9 /src
parent078f588cef389358adabc579de00747878f3c108 (diff)
parent0e21a867a572679d64d79041eb574d13665178d4 (diff)
downloadpackages_providers_ContactsProvider-ae94a710dbc0ea239277c25986e39ba53904c5fc.zip
packages_providers_ContactsProvider-ae94a710dbc0ea239277c25986e39ba53904c5fc.tar.gz
packages_providers_ContactsProvider-ae94a710dbc0ea239277c25986e39ba53904c5fc.tar.bz2
Merge "Change Settings insert conflict to do an update." into ics-factoryrom
Diffstat (limited to 'src')
-rw-r--r--src/com/android/providers/contacts/ContactsProvider2.java16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/com/android/providers/contacts/ContactsProvider2.java b/src/com/android/providers/contacts/ContactsProvider2.java
index 6189240..f0aa549 100644
--- a/src/com/android/providers/contacts/ContactsProvider2.java
+++ b/src/com/android/providers/contacts/ContactsProvider2.java
@@ -3048,8 +3048,20 @@ public class ContactsProvider2 extends AbstractContactsProvider
Cursor c = queryLocal(settingsUri.build(), null, null, null, null, 0);
try {
if (c.getCount() > 0) {
- throw new SQLiteConstraintException("Can't insert a settings record with the same "
- + "account name/type/data set");
+ // If a record was found, replace it with the new values.
+ String selection = null;
+ String[] selectionArgs = null;
+ if (accountName != null && accountType != null) {
+ selection = Settings.ACCOUNT_NAME + "=? AND " + Settings.ACCOUNT_TYPE + "=?";
+ if (dataSet == null) {
+ selection += " AND " + Settings.DATA_SET + " IS NULL";
+ selectionArgs = new String[] {accountName, accountType};
+ } else {
+ selection += " AND " + Settings.DATA_SET + "=?";
+ selectionArgs = new String[] {accountName, accountType, dataSet};
+ }
+ }
+ return updateSettings(uri, values, selection, selectionArgs);
}
} finally {
c.close();