群导入数据到手机通讯录
1.核心代码:
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;}
<uses-permission android:name="android.permission.WRITE_CONTACTS" /><uses-permission android:name="android.permission.READ_CONTACTS" /><uses-permission android:name="android.permission.READ_PHONE_STATE" />