如何使用内容提供商加入限制条款 [英] How to add limit clause using content provider
本文介绍了如何使用内容提供商加入限制条款的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有没有办法来限制从内容提供者返回的行数? 我发现,但是,它并没有为我工作这解决方案。所有的行仍然被返回。
开放的URI = Playlists.createIdUri(playlistId); //生成URI
URI = uri.buildUpon()appendQueryParameter(限制,3)建()。
光标光标= activity.managedQuery(playlistUri,NULL,NULL,NULL,NULL);
解决方案
我有这个问题,必须打破我的头,直到我终于想通了,或者说得到了为我工作的一个whay。请尝试以下
光标光标= activity.managedQuery(playlistUri,NULL,NULL,NULL,ASC+限制2);
最后一个参数是排序顺序。我公司提供的排序顺序,并追加了极限吧。请确保你给的空间正常。我检查了正在形成的查询,这似乎工作。
Is there a way to limit the number of rows returned from content provider? I found this solution, however, it did not work for me. All of the rows are still being returned.
Uri uri = Playlists.createIdUri(playlistId); //generates URI
uri = uri.buildUpon().appendQueryParameter("limit", "3").build();
Cursor cursor = activity.managedQuery(playlistUri, null, null, null, null);
解决方案
I have had this issue and had to break my head till I finally figured it out, or rather got a whay that worked for me. Try the following
Cursor cursor = activity.managedQuery(playlistUri, null, null, null, " ASC "+" LIMIT 2");
The last parameter is for sortOrder. I provided the sort order and also appended the LIMIT to it. Make sure you give the spaces properly. I had to check the query that was being formed and this seemed to work.
这篇关于如何使用内容提供商加入限制条款的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文