public void updateLessonBooked(ArrayList<Lesson_Booked> array_lesson) { // TODO Auto-generated method stub SQLiteDatabase db = this.getWritableDatabase(); for (int i = 0; i < array_lesson.size(); i++) { Lesson_Booked lesson = array_lesson.get(i); // String selectQuery1 = "SELECT * FROM "+TABLE_PARENTS_DETAILS +" where "+PID+"="+ // ParentList.getParentId(); try { ContentValues values = new ContentValues(); values.put(LID, lesson.getID()); values.put(Description, lesson.getDescription()); values.put(Starttime, lesson.getStart_timing()); values.put(Endtime, lesson.getEnd_timing()); values.put(LessonDate, lesson.getDate()); // cursor = (SQLiteCursor) db.rawQuery(selectQuery1, null); // if (cursor.moveToFirst()) { // updating row // int a=db.update(TABLE_PARENTS_DETAILS, values, PID + " = ?", // new String[] { String.valueOf(ParentList.getParentId()) }); // }else{ db.insert(TABLE_LESSON_BOOKED, null, values); // } } catch (Exception e) { e.printStackTrace(); } } db.close(); }
// 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; } }