【转】透过电话号码查找联系人

【转】通过电话号码查找联系人
示例代码,2.1上调试通过:
public String getContactIDFromPhoneNum(String phoneNum) {
String contactId = "";
ContentResolver cr = getContentResolver();
Cursor pCur = cr.query(
ContactsContract.CommonDataKinds.Phone.CONTENT_URI, null,
ContactsContract.CommonDataKinds.Phone.NUMBER + " = ?",
new String[] { phoneNum }, null);
if (pCur.moveToFirst()) {
contactId = pCur
.getString(pCur
.getColumnIndex(ContactsContract.CommonDataKinds.Phone.CONTACT_ID));
pCur.close();
}
return contactId;
}

希望会有帮助