am using this way to get _id of selected contact

    String column[]={RawContacts._ID};
        Cursor temp=activity.managedQuery(contactData, column, null, null,
null);
          if(temp.moveToFirst())
          {  id=temp.getLong(0);}

and then creating rawContacturi...

        Uri rawContactUri =
ContentUris.withAppendedId(RawContacts.CONTENT_URI,
                id);

On Tue, Oct 26, 2010 at 5:25 PM, Prakash Iyer <thei...@gmail.com> wrote:

> You might be using the contact id as id of raw contact. Isn't clear that's
> the problem as I didn't bother to go thru your logic for contactData but
> that would result in a problem like what you are describing...
> On Oct 26, 2010 7:40 AM, "A N K ! T" <ankit.awasth...@gmail.com> wrote:
> > while am trying to pick a contact from phone book it is returning another
> > contact...
> > i dont know what happening..
> > this is my code....
> >
> > .//*contactData is uri getting from onActivity result*
> >
> > *String[] parts = contactData.toString().split("/");
> > long id = Long.parseLong(parts[parts.length - 1]);
> > Uri rawContactUri =
> > ContentUris.withAppendedId(RawContacts.CONTENT_URI,
> > id);
> > Uri entityUri = Uri.withAppendedPath(rawContactUri,
> > Entity.CONTENT_DIRECTORY);
> >
> > Cursor c = activity
> > .managedQuery(
> > entityUri,
> > new String[] { Entity.MIMETYPE, Entity.DATA1,
> > Phone.TYPE },
> > Entity.MIMETYPE + "=? OR " + Entity.MIMETYPE + "=?",
> > new String[] {
> >
> > ContactsContract.CommonDataKinds.Phone.CONTENT_ITEM_TYPE,
> >
> > ContactsContract.CommonDataKinds.StructuredName.CONTENT_ITEM_TYPE },
> > null);
> > String NumbersData[][] = new String[c.getCount() - 1][2];
> > number_type = new String[c.getCount() - 1];
> > if (c.moveToFirst()) {
> > do {
> > String mimeType = c.getString(0);
> >
> >
> > if (mimeType
> >
> >
> .equals(ContactsContract.CommonDataKinds.StructuredName.CONTENT_ITEM_TYPE))
> > {
> > NAME = c.getString(1);
> > Log.d(TAG, "Name: " + NumbersData);
> > } else if (mimeType
> >
> > .equals(ContactsContract.CommonDataKinds.Phone.CONTENT_ITEM_TYPE)) {
> > NumbersData[i][0] = c.getString(2); // this is
> > number type
> > NumbersData[i][1] = c.getString(1); //this is the
> > number
> > i++;
> > Log.d(TAG, "Phone: " + NumbersData);
> > }
> > } while (c.moveToNext());*
> >
> > --
> >
> > A N K ! T......
> >
> > --
> > 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<android-developers%2bunsubscr...@googlegroups.com>
> > 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 android-developers@googlegroups.com
> To unsubscribe from this group, send email to
> android-developers+unsubscr...@googlegroups.com<android-developers%2bunsubscr...@googlegroups.com>
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en




-- 

 A N K ! T......

-- 
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