How do i order my SQLITE database in descending order, for an android app?

后端 未结 11 1700
死守一世寂寞
死守一世寂寞 2020-11-27 16:44

What is the most efficient method of showing my data in descending order?

public String getRank() {

    String[] rank = new String[]{ KEY_ROWID };
    Curso         


        
11条回答
  •  悲&欢浪女
    2020-11-27 17:25

    According to docs:

    public Cursor query (String table, String[] columns, String selection, String[] selectionArgs, String groupBy, String having, String orderBy, String limit);
    

    and your ORDER BY param means:

    How to order the rows, formatted as an SQL ORDER BY clause (excluding the ORDER BY itself). Passing null will use the default sort order, which may be unordered.

    So, your query will be:

     Cursor cursor = db.query(TABLE_NAME, null, null,
                null, null, null, KEY_ITEM + " DESC", null);
    

提交回复
热议问题