我有一个这样的查询:
Cursor _cursor = mbd.query(SQLITE_TABLE, new String[] {KEY_ROWID,
KEY_SYLLABICATION, KEY_WORD, KEY_PARTOFSPEECH, KEY_MEANING, KEY_SPEAKWORD},
null, null, null, null, null, null);
我只是想限制从数据库中获取的行。
根据文档,您将该LIMIT
子句作为第八个参数传递给query
:
Cursor _cursor = mdb.query(SQLITE_TABLE,
new String[] { KEY_ROWID, KEY_SYLLABICATION,
KEY_WORD, KEY_PARTOFSPEECH,
KEY_MEANING, KEY_SPEAKWORD },
null, null, null, null, null,
"10");
尝试这个
cursor = resolver.query(STORAGE_URI, projection,
Media.BUCKET_DISPLAY_NAME + "=?",
new String[] { folderName },
" _id asc limit " + num);
或试试这个
final String orderBy = Constants.TABLE_CONVERSATION_FIELD_DATE + " DESC";
final String limit= 10;
return db.query(table, columns, selection, selectionArgs, groupBy, having, orderBy, limit);