开发者

how make ordring in this sqlite command?

开发者 https://www.devze.com 2023-02-03 02:19 出处:网络
i have this sqllite query in android .. //---retrieves al开发者_运维技巧l the titles--- public Cursor getAllMessages()

i have this sqllite query in android ..

 //---retrieves al开发者_运维技巧l the titles---
    public Cursor getAllMessages() 
    {
        return db.query(true,DATABASE_TABLE, new String[] {
                KEY_ROWID, 
                KEY_FROMID,
                KEY_TOID,
                KEY_MESSAGE,
                DIR},
                null,
                null, 
                null, 
                null, 
                null, 
                null);
    }

i want to order desc the result according to KEY_ROWID how ?


I have a demo on using SQLite on Android and if you take a look at the PicasaAlbumManager#getAlbumCursor you can see how to set your OrderBy value.

In your case you would most likely do this:

String[] projection = new String[] {KEY_ROWID, KEY_FROMID, KEY_TOID, KEY_MESSAGE, DIR};
db.query(true, DATABASE_TABLE, projection, null, null, null, null, KEY_ROWID, null);

References:

  • Android Developer Documentation - SQLiteDatabase


The query function has an orderBy String parameter, you pass exactly what you would to normally do a descending sort in a standard query, except that you omit ORDER BY.

0

精彩评论

暂无评论...
验证码 换一张
取 消