Android 2.1 How to get Phone Numbers of contacts

Brandon Delany picture Brandon Delany · May 25, 2010 · Viewed 15k times · Source

I'm using this code to retrieve all contact names and phone numbers:

String[] projection = new String[]
{
    People.NAME,
    People.NUMBER
};

Cursor c = ctx.getContentResolver().query(People.CONTENT_URI, projection, null, null, People.NAME + " ASC");
c.moveToFirst();

int nameCol = c.getColumnIndex(People.NAME);
int numCol = c.getColumnIndex(People.NUMBER);

int nContacts = c.getCount();

do
{
  // Do something
} while(c.moveToNext());

However, this will only return the primary number for each contact, but I want to get the secondary numbers as well. How can i do this?

Answer