0
我想要得到的所有再编码由decending日期如何使用排序依据日期以毫秒为单位
我尝试下面的方法
MySQLiteHelper.COLUMN_DATE
包含以毫秒为单位的日期字符串(如1411982657593)orderd。不过,我仍然收到创作的订单,而不是选定的日期。我应该修复什么?
public ArrayList<MyCelebration> getAllComments() {
ArrayList<MyCelebration> myCelebrations = new ArrayList<MyCelebration>();
String orderBy = "datetime("+MySQLiteHelper.COLUMN_DATE + ") DESC";
Cursor cursor = database.query(
MySQLiteHelper.TABLE_CELEBRATION, allColumns, null, null, null, null, orderBy
);
cursor.moveToFirst();
while (!cursor.isAfterLast()) {
MyCelebration myCelebration = cursorToComment(cursor);
myCelebrations.add(myCelebration);
cursor.moveToNext();
}
// make sure to close the cursor
cursor.close();
return myCelebrations;
}
'字符串ORDERBY = MySQLiteHelper.COLUMN_DATE + “DESC”;'?? – Selvin 2014-09-29 09:28:38
“datetime()”不是必需的。排序依据会给你从最高的COLUMN_DATE到最低的行。 – 2014-09-29 09:28:54
我认为'orderBy = MySQLiteHelper.COLUMN_DATE +“DESC”;'应该足够了 – Blackbelt 2014-09-29 09:28:59