0

I have the following problem:

I have a RawContactID and want to get every information about this contact. I run a query like this:

String selection = ContactsContract.RawContactsEntity.RAW_CONTACT_ID +" = ?";
String[] selectionArgs = new String[]{contacts[0].get(0)};
Cursor cursor = getContentResolver().query(ContactsContract.Data.CONTENT_URI, null, selection, selectionArgs, null);

After that I run the cursor through a lot of elseif-Statemens to distinguish betweene the different MIME-Types and read the informations. Works fine, besides that it is very much code only to read informations about one contact, but ok.

The problem is that the MIME-Type for Mobilephonenumber and Telephonenumber are the same (vnd.android.cursor.item/phone_v2)??

How can i distinguish between those to different informations?

Any hint is highly appreciated!

Christoph Haefner
  • 1,093
  • 1
  • 9
  • 25

1 Answers1

2

ContactsContract.CommonDataKinds.Phone will let you distinguish between the types. There is a long list of which TYPE_HOME and TYPE_MOBILE are just two.

The sdk reference also states

You can use all columns defined for ContactsContract.Data as well as the following aliases.

techi.services
  • 8,473
  • 4
  • 39
  • 42
  • Hell not, then I have to switch-case _all_ MIME-Typs AND _all_ Data-Typs *argh* That will be a lot of code ... But thanks anyway, perfect answer :) – Christoph Haefner Dec 31 '10 at 15:04