public Uri getContactUri(String contactId, Context context) { if (context == null || contactId == null) { return null; } //获取联系人信息的Uri Uri uri = ContactsContract.Contacts.CONTENT_URI; //获取ContentResolver ContentResolver contentResolver = context.getContentResolver(); //查询数据,返回Cursor Cursor cursor = contentResolver.query(uri, null, null, null, null); while (cursor.moveToNext()) { //获取联系人的ID String id = cursor.getString(cursor.getColumnIndex(ContactsContract.Contacts._ID)); //获取联系人的姓名 String name = cursor.getString(cursor.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME)); String lookupKey = cursor.getString(cursor.getColumnIndex(ContactsContract.Contacts.LOOKUP_KEY)); if (id != null && id.equals(contactId)) { return ContactsContract.Contacts.getLookupUri(Integer.valueOf(contactId), lookupKey); } } return null; }