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

后端 未结 11 1701
死守一世寂寞
死守一世寂寞 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:35

    This a terrible thing! It costs my a few hours! this is my table rows :

    private String USER_ID = "user_id";
    private String REMEMBER_UN = "remember_un";
    private String REMEMBER_PWD = "remember_pwd";
    private String HEAD_URL = "head_url";
    private String USER_NAME = "user_name";
    private String USER_PPU = "user_ppu";
    private String CURRENT_TIME = "current_time";
    
    Cursor c = db.rawQuery("SELECT * FROM " + TABLE +" ORDER BY " + CURRENT_TIME + " DESC",null);
    

    Every time when I update the table , I will update the CURRENT_TIME for sort. But I found that it is not work.The result is not sorted what I want. Finally, I found that, the column "current_time" is the default row of sqlite.

    The solution is, rename the column "cur_time" instead of "current_time".

提交回复
热议问题