incubator-callback-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From macdo...@apache.org
Subject [2/3] git commit: CB-75 contact.remove does not remove the contact fully
Date Mon, 06 Feb 2012 15:16:30 GMT
CB-75 contact.remove does not remove the contact fully


Project: http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/commit/54968b75
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/tree/54968b75
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/diff/54968b75

Branch: refs/heads/master
Commit: 54968b755b410c5964779a8a005ff72cf2a5d52f
Parents: d8d7c29
Author: Anis Kadri <anis.kadri@gmail.com>
Authored: Fri Feb 3 19:32:31 2012 -0800
Committer: macdonst <simon.macdonald@gmail.com>
Committed: Mon Feb 6 10:13:57 2012 -0500

----------------------------------------------------------------------
 .../org/apache/cordova/ContactAccessorSdk5.java    |   17 ++++++++++++--
 1 files changed, 14 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/54968b75/framework/src/org/apache/cordova/ContactAccessorSdk5.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/ContactAccessorSdk5.java b/framework/src/org/apache/cordova/ContactAccessorSdk5.java
index 31d4c00..ea78758 100644
--- a/framework/src/org/apache/cordova/ContactAccessorSdk5.java
+++ b/framework/src/org/apache/cordova/ContactAccessorSdk5.java
@@ -1617,9 +1617,20 @@ public class ContactAccessorSdk5 extends ContactAccessor {
    * @param id the unique ID of the contact to remove
    */
   public boolean remove(String id) {
-      int result = mApp.getContentResolver().delete(ContactsContract.Data.CONTENT_URI, 
-          ContactsContract.Data.CONTACT_ID + " = ?", 
-          new String[] {id});     
+        int result = 0;
+        Cursor cursor = mApp.getContentResolver().query(ContactsContract.Contacts.CONTENT_URI,

+                                                        null,
+                                                        ContactsContract.Contacts._ID + "
= ?",
+                                                        new String[] {id}, null);
+        if(cursor.getCount() == 1) {
+            cursor.moveToFirst();
+            String lookupKey = cursor.getString(cursor.getColumnIndex(ContactsContract.Contacts.LOOKUP_KEY));
+            Uri uri = Uri.withAppendedPath(ContactsContract.Contacts.CONTENT_LOOKUP_URI,
lookupKey);
+            result = mApp.getContentResolver().delete(uri, null, null);
+        } else {
+          Log.d(LOG_TAG, "Could not find contact with ID");
+        }
+
       return (result > 0) ? true : false;
   } 
 


Mime
View raw message