Android 把电话保存到现有联系人 已有联系人

时间:2021-10-17 22:52:48
Android  把电话保存到现有联系人 已有联系人

  搜索了很长时间,想找个把电话保存到现有联系人的代码,就是打开选中的联系人编辑界面,然后自动添加电话,再手动保存,就跟手机上的一样,功夫不负有心人,终于给搜到了,很不容易啊,现分享如下,

 // 保存至现有联系人
public void saveExist(String name, String phone) {
Intent intent = new Intent(Intent.ACTION_INSERT_OR_EDIT);
intent.setType("vnd.android.cursor.item/person");
intent.setType("vnd.android.cursor.item/contact");
intent.setType("vnd.android.cursor.item/raw_contact");
// intent.putExtra(android.provider.ContactsContract.Intents.Insert.NAME, name);
intent.putExtra(android.provider.ContactsContract.Intents.Insert.PHONE, phone);
intent.putExtra(android.provider.ContactsContract.Intents.Insert.PHONE_TYPE, 3);
startActivity(intent);
}

  由于现有联系人已经有名称,故把修改联系人名称的代码注释掉。