- private Uri insertContact(Context context, String name, String phone) {
- ContentValues values = new ContentValues();
- values.put(People.NAME, name);
- Uri uri = getContentResolver().insert(People.CONTENT_URI, values);
- Uri numberUri = Uri.withAppendedPath(uri, People.Phones.CONTENT_DIRECTORY);
- values.clear();
- values.put(Contacts.Phones.TYPE, People.Phones.TYPE_MOBILE);
- values.put(People.NUMBER, phone);
- getContentResolver().insert(numberUri, values);
- return uri;
- }
- //该片段来自于http://www.codesnippet.cn/detail/250120131926.html
来源: http://www.codesnippet.cn/detail/250120131926.html