You don't have to use a batch. Whatever arguments you specify as batch parameters should also work directly.
Traditionally, we use contacts._ID for deletion, not the name - you can have multiple contacts with the same name. Also, sql parameters should always be passed using placeholders (question mark) and an array of arguments. In your specific code the specific display name is interpreted incorrectly and either throws an exception or deletes nothing. Also, stylistically you want to use Contacts.DISPLAY_NAME, not Phone.DISPLAY_NAME. They do have the same value, but the code would easier to read. I hope this helps, Dmitri On May 28, 2010 10:19 AM, "Pinheiro" <[email protected]> wrote: > I was trying to delete a contact using the code in the docs: > > ArrayList<ContentProviderOperation> ops = Lists.newArrayList(); > ops.add(ContentProviderOperation.newDelete(Data.CONTENT_URI) > .withSelection(Data._ID + "=?", new String[] > {String.valueOf(dataId)}) > .build()); > getContentResolver().applyBatch(ContactsContract.AUTHORITY, ops); > > But Eclipse doesn't how to find "Lists". What import statement do I > need? > > Also, is there a more direct way to delete a contact? Thanks in > advance! > > -- > You received this message because you are subscribed to the Google > Groups "Android Developers" group. > To post to this group, send email to [email protected] > To unsubscribe from this group, send email to > [email protected]<android-developers%[email protected]> > For more options, visit this group at > http://groups.google.com/group/android-developers?hl=en -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

