Retrieve Data from Sqllite DB between Two dates android

前端 未结 4 1042
盖世英雄少女心
盖世英雄少女心 2020-12-22 13:17

I retrieve data between two dates some how it get correct result and some how it output empty listview when i select dates with month it work properly but when i select dat

4条回答
  •  悲哀的现实
    2020-12-22 13:32

    you need to store date inform of yyyy-mm-dd and then use this method simply call getWeekData(start_date, end_date);

    public Object getWeekData(String start_date, String end_date) {
            if (!mDataBase.isOpen())
                openDataBase();
    
            Object data = new Object ();
            // Select All Query
            String query = (String) ("Select * from " + TBL_NAME 
                    + " where " + (COL_DATE + " between '" + start_date + "' AND '" + end_date + "'"));
            Cursor cursor = mDataBase.rawQuery(query, null);
            // looping through all rows and adding to list
    
            if (cursor.moveToFirst()) {
                do {
                    //get data over here
                } while (cursor.moveToNext());
            }
    
            // closing connection
            cursor.close();
            close();
            return data;
        }
    

提交回复
热议问题