我想订购一个数据库 - 但它不起作用
是
ORDER BY <Field> ASC
android的声明?
答案 0 :(得分:0)
您无法“订购”数据库。但是,您可以使用适当的查询重载来排序查询结果。
public Cursor query (String table, String[] columns, String selection, String[] selectionArgs, String groupBy, String having, String orderBy)
例如:
db.query("someTable", new String[] { "ColumnA", "ColumnB" }, "WHERE ColumnC = ?",
new String[] { "ColumnC_Condition" }, "ColumnB", null, "ColumnA");
转换为
SELECT ColumnA, ColumnB FROM someTable WHERE ColumnC = "ColumnC_Condition"
GROUP BY ColumnB ORDER BY ColumnA