TABLE_NAME (COL1, COL2, COL3, COL4);
Cursor cur = db.query(TABLE_NAME, null, null, null, null, null, COL1);
This way we get the entries ordered by COL1 values. If some of them has the same COL1 value SQLite uses the same order as when they were stored by the previous insertions.
Is it possible to define many degrees of sorting? For example, if two or more entries has the same COL1 value then the one with the smaller COL2 value will go first and so on.
Android site says that we can specify only a String (column) for the sorting.
query(String table, String[] columns, String selection, String[] selectionArgs, String groupBy, String having, String orderBy)
If I use a
db.rawQuery("sql code")
the string of sql code will be compiled at runtime so the program will be slower. I would like to avoid that if not necessary. Are there any other ways?
Aucun commentaire:
Enregistrer un commentaire