如何在Android的限制条款添加到manageQuery条款、如何在、Android、manageQuery

2023-09-05 04:19:23 作者:可以杀我但别用感情刀

Android的API提供了通过SQLite的清洁机制,使查询到联系人列表。但是,我不知道如何限制的结果:

Android's API provides a clean mechanism via SQLite to make queries into the contact list. However, I am not sure how to limit the results:

Cursor cur = ((Activity)mCtx).managedQuery(
                People.CONTENT_URI,
                columns,
                "LIMIT ? OFFSET ?",
                new String[] { Integer.toString(limit), Integer.toString(offset) },
                null
        );

不能正常工作。

Doesn't work.

推荐答案

其实,根据不同的供应商,你可以按如下附加限制到URI:

Actually, depending on the provider you can append a limit to the URI as follows:

uri.buildUpon().appendQueryParameter("limit", "40").build()

我知道MediaProvider处理这和看近code似乎可以与联系人也做到这一点。

I know the MediaProvider handles this and from looking at recent code it seems you can do it with contacts too.