Why do I need to find a contact by display name?
In my app, I wanted to open a specific contact and add another phone number to it
flushing, dyspepsia, nasal stuffiness and transient alteredGardening (digging) 3-5 How does cialis work?.
. I didn’t have the contact id of the contact, only the display name.
Get the first contact with the name “John Johnson”
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
contentResolver = context.getContentResolver(); Uri uri = Data.CONTENT_URI; String[] projection = new String[] { PhoneLookup._ID }; String selection = StructuredName.DISPLAY_NAME + " = ?"; String[] selectionArguments = { "John Johnson" }; Cursor cursor = contentResolver.query( uri, projection, selection, selectionArguments, null); if (cursor != null) { while (cursor.moveToNext()) { return cursor.getString(0); } } return "John Johnson not found"; |