添加联系人1.6

final String name = "reader"; // find "reader"'s contact  String select = String.format("%s=? AND %s='%s'",         Data.DISPLAY_NAME, Data.MIMETYPE, Phone.CONTENT_ITEM_TYPE); String[] project = new String[] { Data.RAW_CONTACT_ID }; Cursor c = getContentResolver().query(         Data.CONTENT_URI, project, select, new String[] { name }, null); long rawContactId = -1; if(c.moveToFirst()){     rawContactId = c.getLong(c.getColumnIndex(Data.RAW_CONTACT_ID)); } c.close();

ContentValues values = new ContentValues(); values.put(Data.RAW_CONTACT_ID, rawContactId); values.put(Data.MIMETYPE, Phone.CONTENT_ITEM_TYPE); values.put(Phone.NUMBER, "1-800-GOOG-411"); values.put(Phone.TYPE, Phone.TYPE_CUSTOM); values.put(Phone.LABEL, "free directory assistance"); Uri dataUri = getContentResolver().insert(Data.CONTENT_URI, values);

你可能感兴趣的:(C++,c,C#)