Possible to get "Owner" contact info in Android?

wajiw picture wajiw · Jun 3, 2011 · Viewed 12.4k times · Source

I haven't been able to find a straight answer on this. Can anyone tell me if it's possible to get the contact info of the phone's owner in an Android App?

Answer

Daksh picture Daksh · Oct 15, 2012

I have found a very easy way (got it from digging into the 4.1 Messaging app!)

projection for cursor is

final String[] SELF_PROJECTION = new String[] { Phone._ID,Phone.DISPLAY_NAME, };

Cursor is :

Cursor cursor = activity.getContentResolver().query(Profile.CONTENT_URI, SELF_PROJECTION, null, null, null);

now just do a simple

cursor.moveToFirst():

and then fetch the contact id via

cursor.getString(0)

and the contact name via

cursor.getString(1)

and..... you're done!