How to retrieve *phone* contact info

Put your problem here if it does not fit any of the other categories.

How to retrieve *phone* contact info

Postby PaulFake » Thu Oct 01, 2009 6:43 am

Hi,

I need to retrieve the names, numbers, and email addresses of all the people in the contacts directory of my phone. I thought the following code would do the trick:

String columns[] = {People.NAME, People.NUMBER, Contacts.People.PRIMARY_EMAIL_ID};
Cursor c = getContentResolver().query(People.CONTENT_URI, columns, null, null, null);
m_aryContacts = new ContactInfo[c.getCount()];
c.moveToFirst();
for(int i = 0; i < c.getCount(); i++)
{
ContactInfo info = new ContactInfo(c.getString(c.getColumnIndex(People.NAME)),
c.getString(c.getColumnIndex(People.NUMBER)),
c.getString(c.getColumnIndex(People.PRIMARY_EMAIL_ID)));
m_aryContacts[i] = info;
c.moveToNext();
}


But this actually retrieves all the contact info from the GMail account that I entered when setting up the phone. I am not interested in retrieving my GMail contacts...only the contacts that I have manually entered into the phone (you know...when you click on "Contacts" on the phone's home screen). Does anybody know how to do this?
PaulFake
Junior Developer
Junior Developer
 
Posts: 21
Joined: Wed Aug 26, 2009 1:05 am

Top

Postby Sowmya » Thu Oct 01, 2009 8:05 am

The above code retieves the contacts manually entered .May be some problem wrt contacts synced.
Sowmya
Experienced Developer
Experienced Developer
 
Posts: 51
Joined: Fri Mar 06, 2009 7:49 am

Postby PaulFake » Thu Oct 01, 2009 8:41 am

Hmmm...lame. I was actually able to retrieve the contacts I wanted by using Phones.CONTENT_URI instead, but this table does not contain any information about email addresses, annoyingly enough.
PaulFake
Junior Developer
Junior Developer
 
Posts: 21
Joined: Wed Aug 26, 2009 1:05 am

Postby Sowmya » Mon Oct 05, 2009 7:40 am

Check this link

viewtopic.php?p=20351
Sowmya
Experienced Developer
Experienced Developer
 
Posts: 51
Joined: Fri Mar 06, 2009 7:49 am

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: Exabot [Bot] and 17 guests