4
我使用的ContentProvider,並SQLiteQueryBuilder:SQLiteQueryBuilder反向排序
@Override
public Cursor query(Uri uri, String[] projection, String selection,
String[] selectionArgs, String sortOrder) {
SQLiteQueryBuilder qb = new SQLiteQueryBuilder();
qb.setTables(NEWS_TABLE);
switch(sUriMatcher.match(uri)){
case NEWS_ITEM_ID: qb.appendWhere(KEY_ID+ "=" + uri.getPathSegments().get(1));
break;
default: break;
}
String orderBy;
if (TextUtils.isEmpty(sortOrder)) {
orderBy = KEY_DATE;
} else {
/* ______ WANT TO REVERSE IT HERE _____ */
orderBy = sortOrder;
}
Cursor c = qb.query(newsDB,
projection,
selection, selectionArgs,
null, null,
orderBy);
c.setNotificationUri(getContext().getContentResolver(), uri);
return c;
}
如何使用反向排序順序查詢?謝謝你的幫助。