需要多少次查询才能获取 Android 联系人组中每个人的姓名和号码?

发布于 2024-09-28 13:30:49 字数 231 浏览 2 评论 0原文

使用 Android 2.0 ContactsContract API,是否可以构建代表联系人组中联系人的对象列表,如下所示:

public class GroupContact {  
    public String displayName;
    public List<String> phoneNumbers;
}

同时进行少于 O(n) SQL 查询?

Using the Android 2.0 ContactsContract API, is it possible to build a list of objects representing contacts in a Contact Group like this:

public class GroupContact {  
    public String displayName;
    public List<String> phoneNumbers;
}

While making fewer than O(n) SQL queries?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

浅笑轻吟梦一曲 2024-10-05 13:30:49

也许,这取决于几件事。

我认为 n 是指显示名称的电话号码数量。

我怀疑您所说的查询实际上是指cursor.moveToNext() 调用。

在任何情况下,您所寻找的内容都可以通过一个具有 n-1 moveTo*() 调用的查询来完成。
该查询使用“view_data”视图。

在您想要的内容提供商方面...

SELECT * FROM "view_data" WHERE "display_name" = 'mo howard';

或从 ContentResolver

Maybe, it depends on a couple of things.

I presume by n you mean the number of phone numbers for the display name.

By queries I suspect you really mean cursor.moveToNext() calls.

In any case what you are looking for can be done with one query having n-1 moveTo*() calls.
The query makes use of the "view_data" view.

On the content provider side you want...

SELECT * FROM "view_data" WHERE "display_name" = 'mo howard';

or from the ContentResolver

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文