为 ContentProvider 查询指定限制/偏移量 [英] Specifying limit / offset for ContentProvider queries
本文介绍了为 ContentProvider 查询指定限制/偏移量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试让我的 ContentResolver 运行此查询:
I'm trying to get my ContentResolver to run this query:
select * from myTable limit 1 offset 2
ContentResolver 中唯一的 query 方法是:
The only query method in ContentResolver is:
resolver.query(uri, projection, selection, selectionArgs, sortOrder);
我试过了:
final Cursor c = resolver.query(
MyTable.CONTENT_URI,
MyTable.PROJECTION,
" ? ?",
new String[] {"1", "2"},
null);
这只是抛出一个 IllegaLArgumentException.实现这一目标的正确方法是什么?
Which just throws an IllegaLArgumentException. What is the correct way of achieving this?
推荐答案
我将 LIMIT 子句放在 sordOrder 参数中,我也看到其他人做过同样的事情,但不确定它是否 100% 正确:
I put the LIMIT clause in the sordOrder parameter, I've also seen the same thing done by others but not sure if its 100% correct:
final Cursor c = resolver.query(
MyTable.CONTENT_URI,
MyTable.PROJECTION,
null,
null,
" limit 1 offset 2");
这篇关于为 ContentProvider 查询指定限制/偏移量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文