获取电话号码并加入我自己的桌子
我知道如何获取电话号码:
Cursor cursor = contentResolver.query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI, selection, where, whereArgs, orderBy);
但我有自己的表,它已在我的应用程序中将某些电话号码标记为“黑名单”。我想将电话号码加入到这张表中。发出两个数据库请求然后迭代游标以匹配数字需要很长时间。我怎样才能以聪明而有效的方式做到这一点?
问候,
I know how to get phone numbers:
Cursor cursor = contentResolver.query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI, selection, where, whereArgs, orderBy);
But I have my own table, that has marked certain phone numbers as "blacklisted" in my app. I would like to join the phone numbers with this table. It takes way to long time to make two database-requests and then iterate over the cursors to match the numbers. How can I make this in a smart and effective way?
Regards,
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
纯理论:将列入黑名单的号码写入表中,并使保存该号码的列唯一。不要重复检查黑名单号码。只需尝试插入到您的黑名单号码列中,并发现它是重复的。想法?
Purely theoretical: write the blacklisted number into a table and make the column that holds the number unique. Don't iterate through checking for a blacklisted number. Just attempt an insert into your blacklisted number column and catch the case that it would be a duplicate. Thoughts?
我发现 CursorJoiner 很可能就是这样去。如果您找到更好的方法,请纠正我。
I have found that most likely the CursorJoiner is the way to go. Please correct me if you find a better way.