gpt4 book ai didi

android - 如何以编程方式创建联系人

转载 作者:塔克拉玛干 更新时间:2023-11-01 21:45:18 28 4
gpt4 key购买 nike

<分区>

Possible Duplicate:
How to add new contacts in android

public boolean createContact(String name, String number, String email) 
{
boolean success = true;

try
{
ContentValues contentValues = new ContentValues();

ContentResolver contentResolver = getContentResolver();

contentValues.put(Data.MIMETYPE, Phone.CONTENT_ITEM_TYPE);
contentValues.put(Phone.NUMBER, "123254");
Uri uri = contentResolver.insert(android.provider.ContactsContract.Data.CONTENT_URI, contentValues);

if(uri==null)
{
success = false;
}

}
catch (Exception e)
{
e.printStackTrace();
success = false;
}
return success;
}

我收到 NullPointer 异常 我不知道为什么我还指定了 WRITE_CONTACTS 权限。请帮助我......................

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com