When using contentResolver.delete(uri, null, null) then determining
success can be done by looking at the return value of how many rows
were affected.

However, deleting a contact through ContentProviderOperation and
applyBatch returns ContentProviderResult[]

How can you identify whether the delete operation was successful or
not from the ContentProviderResult object?

ArrayList<ContentProviderOperation> ops =
      new ArrayList<ContentProviderOperation>();

ops.add(ContentProviderOperation.newDelete(Data.CONTENT_URI)
      .withSelection(Data._ID + "=?", new String[]
{String.valueOf(dataId)})
      .build());

ContentProviderResult[] results =
getContentResolver().applyBatch(ContactsContract.AUTHORITY, ops);
if (results != null && results[0] != null)
{
    // How to extract whether success or failure from results[0] ?
}


In my testing: (1a) I call the delete method and results.length == 1
(1b) I have a look and the contact is indeed deleted in phone Contact
(2) I call the delete method again even though the targeted contact is
already deleted, but it still returns results.length == 1. And no
exception is thrown...

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to