联系人列表中有多少个联系人
如何知道联系人列表中有多少个联系人?我获得了联系电话号码,但一个人可以有多个联系人,我想在查找联系人列表中的联系人总数时考虑到这一点。
How can I tell how many contacts there are in the contact list? I got the contact number, but one person can have more than one contact and I want to account for this in finding the total number of contacts in the contact list.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
查找所有联系人的电话号码计数
查找特定 RawContactID 的所有电话号码计数(在 rawContactId 中传递联系人 id 值)。
ContactsListActivity 中显示的联系人数量可以通过以下查询确定。
int count = 游标.getCount();
但是,如果一个人已在多个帐户下输入,则上述查询只会获得一个实例,因为 ContactsContract.Contacts 组合了所有此类联系人。
int count = 游标.getCount();
ContactsContract.Contacts 和 RawContacts 之间的关系可以在以下位置找到
http://developer.android.com/resources/articles/contacts.html
希望这能解决您的疑问!
To find the count of phone numbers of all the contacts
To find the count of all the phone numbers of a particular RawContactID (pass the contact id value in rawContactId).
The number of contacts displayed in the ContactsListActivity consists can be determined by following query.
int count = cursor.getCount();
However if a person has been entered under multiple accounts then only a single instance is obtained by the above query as ContactsContract.Contacts combines all such contacts.
int count = cursor.getCount();
The relation between ContactsContract.Contacts and RawContacts can be found out at
http://developer.android.com/resources/articles/contacts.html
Hope this resolves your doubt!
一个非常古老的线程,但如果你想用电话号码来计算联系人,你可以使用这个:
当然,现在不推荐使用 ManagedQuery,但这可以帮助绑定:)
A really old thread, but if you want to count contacts WITH phone numbers you can use this:
Of course managedQuery is deprecated now, but this can help in a bind :)
据我们所知, ManagedQuery 现已被弃用,我们可以像这样完成此任务
As we know managedQuery is now deprecated we can do this task like this
如果有人仍然需要答案:
managementQuery
现已弃用,因此我们将使用query
而不是getContentResolver()
。注意:此答案已在 Android 10、11 和 12 上测试。
If anybody needs still the answer:
managedQuery
is now deprecated, so we'll be usingquery
instead fromgetContentResolver()
.Note: This answer is tested on Android 10, 11 and 12.