简体   繁体   English

如何在 android 和 java 中添加新的电话联系人,并在 json 中提供多个联系人数据

[英]how to add a new phone contact in android iin java with multiple contact data provided in json

current i am trying to make a app where the user and export his phone contacts as a json file and later he can import the json file to the app and can add all the contacts stored in the json file to his ohone contact.目前我正在尝试制作一个应用程序,用户并将他的手机联系人导出为 json 文件,稍后他可以将 json 文件导入应用程序,并可以将存储在 json 文件中的所有联系人添加到他的联系人文件中。

I am unable to find the correct way to do this in java, any help for this is highly appreciated.我无法在 java 中找到正确的方法,对此的任何帮助都非常感谢。

plz note a json file will contain atleast 100 contact and these 100 contacts will have to be added to the phone contact when imported.请注意 json 文件将包含至少 100 个联系人,这 100 个联系人在导入时必须添加到电话联系人中。 Thnks in advance..提前谢谢..

You do this via in-built system Intent您可以通过内置系统 Intent 执行此操作

Intent contactsPage = new Intent(ContactsContract.Intents.Insert.ACTION);
contactsPage.setType(ContactsContract.RawContacts.CONTENT_TYPE);
contactsPage.putExtra(ContactsContract.Intents.Insert.NAME, nameString);
contactsPage.putExtra(ContactsContract.Intents.Insert.PHONE, phoneNumberString);

For further information refer to: https://developer.android.com/reference/android/provider/ContactsContract有关详细信息,请参阅: https://developer.android.com/reference/android/provider/ContactsContract

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM