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.
精彩评论