Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/232.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 选择contentProvider中的前n行_Android_Where_Android Contentprovider - Fatal编程技术网

Android 选择contentProvider中的前n行

Android 选择contentProvider中的前n行,android,where,android-contentprovider,Android,Where,Android Contentprovider,我选择了以下选项: final Cursor cursorConversations = getContentResolver().query( Uri.parse("content://gmail-ls/conversations/" + Uri.encode(mailAddress)), null, null, null, BaseColumns._ID + " DESC"); ContentQueryMap mQueryMap = n

我选择了以下选项:

 final Cursor cursorConversations = getContentResolver().query(
        Uri.parse("content://gmail-ls/conversations/" + Uri.encode(mailAddress)),
        null, null, null, BaseColumns._ID + " DESC");

 ContentQueryMap mQueryMap 
        = new ContentQueryMap(cursorConversations, BaseColumns._ID, true, null);
使用ContentQueyMap,我可以缓存游标数据,并在游标关闭的情况下在其中进行迭代(我需要它来提高性能)

现在,我希望Corsor的select只检索前五十行。在
mQueryMap.getRows().entrySet()
中循环50次的解决方案是不对的:我不希望mQueryMap获取游标的所有行,而只获取前50行


有什么想法吗?是否存在仅获取前n行的where子句?

从表5中选择*

这对sqlite是有效的。尝试在where子句中添加“LIMIT 5”。(我没有试过)

你可以

final Cursor cursorConversations = getContentResolver().query(
    Uri.parse("content://gmail-ls/conversations/" + Uri.encode(mailAddress)),
    null, null, null, BaseColumns._ID + " DESC " + " LIMIT 5");
排序后的“限制x”


干杯是不行的。如果我在“sort子句参数”中输入,ddms会抛出一个异常:“sortOrder必须为空”。。。(为什么??)非常感谢你@克里斯,你能帮我吗