gpt4 book ai didi

java - Android - 光标结果搜索字符串错误,需要搜索 DISPLAY_NAME 进行匹配

转载 作者:行者123 更新时间:2023-11-30 09:41:57 24 4
gpt4 key购买 nike

我需要搜索 DISPLAY_NAME 字段的名字和姓氏,并尝试了以下代码:

ContentResolver cr = getContentResolver(); 
Cursor cur = cr.query(ContactsContract.Contacts.CONTENT_URI, null, ContactsContract.Contacts.DISPLAY_NAME + " like %?%", new String[]{ results.get(0) }, null);

如果 (cur.getCount() > 0) {

我在 log cat 中从光标行中的 % 中得到错误。任何建议将不胜感激。 ??

最佳答案

ContentResolver.query()' ' 放在替代问号周围,所以您需要的是

Cursor cur = cr.query(
ContactsContract.Contacts.CONTENT_URI,
null,
ContactsContract.Contacts.DISPLAY_NAME + " like ?",
new String[]{ "%" + results.get(0) + "%"},
null);

关于java - Android - 光标结果搜索字符串错误,需要搜索 DISPLAY_NAME 进行匹配,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8804179/

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