-2

我有一个这样的查询:

 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);

我只是想限制从数据库中获取的行。

4

2 回答 2

2

根据文档,您将该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");
于 2013-02-13T08:10:18.513 回答
1

尝试这个

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);
于 2013-02-13T04:10:58.063 回答