Reputation: 64844
i have this sqllite query in android ..
//---retrieves all 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 ?
Upvotes: 0
Views: 146
Reputation: 1742
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:
Upvotes: 1
Reputation: 1618
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.
Upvotes: 0