插入联系人函数: public void insert() { //首先插入空值,再得到rawContactsId ,用于下面插值 ContentValues values = new ContentValues (); //insert a null value Uri rawContactUri = getContentResolver().insert(RawContacts.CONTENT_URI,values); long rawContactsId = ContentUris.parseId(rawContactUri); //往刚才的空记录中插入姓名 values.clear(); //A reference to the _ID that this data belongs to values.put(StructuredName.RAW_CONTACT_ID,rawContactsId); //"CONTENT_ITEM_TYPE" MIME type used when storing this in data table values.put(Data.MIMETYPE,StructuredName.CONTENT_ITEM_TYPE); //The name that should be used to display the contact. values.put(StructuredName.DISPLAY_NAME,"LiSi"); //insert the real values getContentResolver().insert(Data.CONTENT_URI,values); //插入电话 values.clear(); values.put(Phone.RAW_CONTACT_ID,rawContactsId); //String "Data.MIMETYPE":The MIME type of the item represented by this row //String "CONTENT_ITEM_TYPE": MIME type used when storing this in data table. values.put(Data.MIMETYPE,Phone.CONTENT_ITEM_TYPE); values.put(Phone.NUMBER,"15955557777"); getContentResolver().insert(Data.CONTENT_URI,values); } 获取联系人函数: public void getContact(){ //获得所有的联系人 Cursor cur = getContentResolver().query(ContactsContract.Contacts.CONTENT_URI, null, null, null, null); //循环遍历 if (cur.moveToFirst()) { int idColumn = cur.getColumnIndex(ContactsContract.Contacts._ID); int displayNameColumn = cur.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME); do { //获得联系人的ID号 String contactId = cur.getString(idColumn); Log.i("contactId",contactId); //获得联系人姓名 String disPlayName = cur.getString(displayNameColumn); Log.i("disPlayName",disPlayName); //查看该联系人有多少个电话号码。如果没有这返回值为0 int phoneCount = cur.getInt(cur.getColumnIndex(ContactsContract.Contacts.HAS_PHONE_NUMBER)); if(phoneCount>0){ //获得联系人的电话号码 Cursor phones = getContentResolver().query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI,null,ContactsContract.CommonDataKinds.Phone.CONTACT_ID+ " = " + contactId, null, null); if(phones.moveToFirst()){ do{ //遍历所有的电话号码 String phoneNumber= phones.getString(phones.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER)); Log.i("phoneNumber",phoneNumber); }while(phones.moveToNext()); } } } while (cur.moveToNext()); } 注意:在程序运行前,电话本中一定要有联系人,否则程序无法正常执行。