How to delete all android contacts that start with a specific name? -
i want delete contacts android phone starts "aaa" or contains "aaa" . here's tried:
private void deletecontact(string name) { contentresolver cr = getcontentresolver(); string = contactscontract.data.display_name + " = ? "; string[] params = new string[] {"aaaa"}; arraylist<contentprovideroperation> ops = new arraylist<contentprovideroperation>(); ops.add(contentprovideroperation.newdelete(contactscontract.rawcontacts.content_uri) .withselection(where, params) .build()); log.e(",,,,",string.valueof(ops.get(0))); try { cr.applybatch(contactscontract.authority, ops); } catch (remoteexception e) { // todo auto-generated catch block e.printstacktrace(); } catch (operationapplicationexception e) { // todo auto-generated catch block e.printstacktrace(); } toast.maketext(nativecontentprovider.this, "deleted contact name '" + name +"'", toast.length_short).show(); }
but failed. please give me idea can proceed further in project.
maybe on right track:
contentresolver mcontentresolver = getcontentresolver(); private int deletecontactslike(string name) { return mcontentresolver.delete( contactscontract.rawcontacts.content_uri, contactscontract.contacts.display_name + " ?", new string[] { name + '%'});
Comments
Post a Comment