开发者

How many queries are required to get the names and numbers of everyone in an Android contact group?

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?


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜