Hi ..

u can try this code

        Cursor c = getContentResolver().query(Phones.CONTENT_URI,
null,"phones._id ="+id, null, null);

this code will return a row contain _id.

first ...

        you try with phone no  to get _id....

Cursor c= context.getContentResolver().query
(Contacts.Phones.CONTENT_URI,
                         Contacts.PhonesColumns.NUMBER+"=9999999999",
null);
now fetch _id from  this row & use it in next query...


it will work.....100% .

i had already tried thi thing.



On Feb 10, 12:51 am, Meryl Silverburgh <silverburgh.me...@gmail.com>
wrote:
> 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
>
> <silverberg.ode...@googlemail.com> 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 <silverburgh.me...@gmail.com>
> > 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:1­30)
> >>         at 
> >> android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:1­10)
> >>         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 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