// get booked date public ArrayList<Lesson_Booked> getLessonBooked(String trigger, String date3, String date4) { ArrayList<Lesson_Booked> arrayList_booked = new ArrayList<Lesson_Booked>(); String selectQuery = null; if (trigger.equals("all")) { selectQuery = "SELECT * FROM " + TABLE_LESSON_BOOKED; } else { selectQuery = "SELECT * FROM " + TABLE_LESSON_BOOKED + " where " + LessonDate + ">=" + date3 + " AND " + LessonDate + "<=" + date4; } SQLiteDatabase db = this.getReadableDatabase(); try { cursor = (SQLiteCursor) db.rawQuery(selectQuery, null); if (cursor.moveToFirst()) { do { Lesson_Booked lesson_booked = new Lesson_Booked(); lesson_booked.setID(cursor.getString(cursor.getColumnIndex(LID))); lesson_booked.setDescription(cursor.getString(cursor.getColumnIndex(Description))); lesson_booked.setStart_timing(cursor.getString(cursor.getColumnIndex(Starttime))); lesson_booked.setEnd_timing(cursor.getString(cursor.getColumnIndex(Endtime))); lesson_booked.setDate(cursor.getString(cursor.getColumnIndex(LessonDate))); arrayList_booked.add(lesson_booked); // array_studentlist.set(studentList); } while (cursor.moveToNext()); } cursor.getWindow().clear(); cursor.close(); // close inserting data from database db.close(); // return city list return arrayList_booked; } catch (Exception e) { e.printStackTrace(); if (cursor != null) { cursor.getWindow().clear(); cursor.close(); } db.close(); return arrayList_booked; } }