Thanks. But can you please tell me how can If I find the _ID from the phone number?
On Mon, Feb 9, 2009 at 6:00 AM, Odessa Silverberg <[email protected]> wrote: > > I'm not 100% sure, but i think it's because you passed > Contacts.Phones.CONTENT_URI instead of creating your own uri which has > an id-segment appended. > The ID is the unique _ID field you have in your phone table.If you > know the _ID you can generate a uri (it's called URI not URL btw :P) > with this line > > > private void removeContact(Context context, String phone) { > long _id = 2; // Just hardcoding it, in your aplication > you have to get the ID programmatically) > Uri deleteContactUri = Uri.withAppendedPath > (Contacts.Phones.CONTENT_URI, String.valueOf(_id)); > > context.getContentResolver().delete(deleteContactUri, > null, null); > } > > On Feb 9, 3:19 am, Meryl Silverburgh <[email protected]> > wrote: >> Hi, >> >> I am getting the "Cannot delete that URL" exception(see below): >> java.lang.UnsupportedOperationException: Cannot delete that URL: >> content://contacts/phones >> at >> android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:130) >> at >> android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:110) >> at >> android.content.ContentProviderProxy.delete(ContentProviderNative.java:362) >> at android.content.ContentResolver.delete(ContentResolver.java:386) >> >> Here is my code: >> private void removeContact(Context context, String phone) { >> >> context.getContentResolver().delete(Contacts.Phones.CONTENT_URI, >> Contacts.PhonesColumns.NUMBER+"=?", new String[] >> {phone}); >> } >> >> Can you please tell me what am I missing? >> >> Thank you. > > > --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---

