How to distinguish between Telephonenumber and Mobilephonenumber
-
14-10-2019 - |
Question
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!
Solution
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.