Hi, you should use the phone URI to retrieve all phone number. With
your code, you can get each person's id and use it like this:

if (column.equals(People._ID)) {
        String whereClause = "person="+contactsCursor.getString
(contactsCursor.getColumnIndex(column));

        String[] phonesProjection = new String[] {Phones.NUMBER,
Phones.TYPE};
        Cursor phonesCursor = managedQuery(Contacts.Phones.CONTENT_URI,
phonesProjection, whereClause, null, null);
        int phonesCursorCount = phonesCursor.getCount();
        if (phonesCursorCount > 0) {
                phonesCursor.moveToFirst();
                int numberColumn = phonesCursor.getColumnIndex(Phones.NUMBER);
                int typeColumn = phonesCursor.getColumnIndex(Phones.TYPE);
                for (int j=0; j<phonesCursorCount; j++) {
                        switch (phonesCursor.getInt(typeColumn)) {
                                case Phones.TYPE_WORK:
                                        workPhone = 
phonesCursor.getString(numberColumn);
                                        break;
                                case Phones.TYPE_HOME:
                                        homePhone = 
phonesCursor.getString(numberColumn);
                                        break;
                                case Phones.TYPE_MOBILE:
                                        mobilePhone = 
phonesCursor.getString(numberColumn);
                                        break;
                                case Phones.TYPE_CUSTOM:
                                        companyPhone = 
phonesCursor.getString(numberColumn);
                                        break;
                                case Phones.TYPE_OTHER:
                                        otherPhone = 
phonesCursor.getString(numberColumn);
                                        break;
                                case Phones.TYPE_FAX_WORK:
                                        faxWork = 
phonesCursor.getString(numberColumn);
                                        break;
                        }
                        phonesCursor.moveToNext();
                }
        }
        closeCursor(phonesCursor);



On 30 déc, 21:46, "Sarath Kamisetty" <[email protected]>
wrote:
> Hi,
>
> Given a contact URI like content://contacts/people/23 I want to dump
> all phone numbers - like home, mobile, work, fax etc. all. However
> when I user managedQuery and got a cursor for this and dumped all the
> column names the only relevant columns I see are "number" and
> "primary_phone" (code shown below). It is not clear how all the phone
> numbers are stored and accessed. I tried looking at Contacts code but
> unable to make out much. Any help is greatly appreciated.
>
> Thanks,
> Sarath
>
>                 Cursor managedCursor = managedQuery(pickedContact,
>                     null, // Which columns to return
>                     null,       // WHERE clause; which rows to return (all 
> rows)
>                     null,       // WHERE clause selection arguments (none)
>                     People.NAME + " ASC"); // Order-by clause
> (ascending by name)
>
>             managedCursor.moveToFirst();
>             int columnCount = managedCursor.getColumnCount();
>             String resStr = new String();
>             for (int i=0; i < columnCount; i++) {
>               resStr += managedCursor.getColumnName(i) + " ";
>             }
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to