按日期从sqlite按升序对列表进行排序

[英]Sort a list in ascending order by date from sqlite


I am having a code for retrieving data like this. I wanted to get records with the dates in the ascending order.I tried using "KEY_DATE_TIME ASC" . but it didnt work.

我有一个代码来检索这样的数据。我想按升序获取日期记录。我尝试使用“KEY_DATE_TIME ASC”。但它没有用。

public Cursor fetchAllReminders() {

return mDb.query(DATABASE_TABLE, new String[] {KEY_ROWID, KEY_TITLE,
        KEY_BODY, KEY_PHONE,KEY_DATE_TIME}, null, null, null, null, null);
}

1 个解决方案

#1


41  

Assuming that KEY_DATE_TIME is a String constant holding the name of the db field, the following should work:

假设KEY_DATE_TIME是一个包含db字段名称的String常量,则以下内容应该有效:

return mDb.query(DATABASE_TABLE, new String[] {KEY_ROWID, KEY_TITLE,
        KEY_BODY, KEY_PHONE,KEY_DATE_TIME}, null, null, null, null, KEY_DATE_TIME + " ASC");
智能推荐

注意!

本站翻译的文章,版权归属于本站,未经许可禁止转摘,转摘请注明本文地址:http://www.silva-art.net/blog/2011/11/08/534e761b5620a730f2f8d1b7f2e5d2e0.html



 
© 2014-2019 ITdaan.com 粤ICP备14056181号  

赞助商广告