/* GET PASSED EXAMS */ public Cursor getPassedExams() { database = course_dbHelper.getWritableDatabase(); String where = DB_ABSTRACTS.DBCourse.PASSED_COLUMN + " = " + 1; Cursor cursor = database.query( DB_ABSTRACTS.DBCourse.DATABASE_TABLE, examColumns, where, null, null, null, DB_ABSTRACTS.DBCourse.PASS_MARK_COLUMN + " ASC"); if (cursor.moveToFirst()) { do { Course course = new Course(); course.setId(cursor.getInt(cursor.getColumnIndex(DB_ABSTRACTS.DBCourse.KEY_ID))); course.setName(cursor.getString(cursor.getColumnIndex(DB_ABSTRACTS.DBCourse.NAME_COLUMN))); course.setPassed(cursor.getInt(cursor.getColumnIndex(DB_ABSTRACTS.DBCourse.PASSED_COLUMN))); course.setPass_mark( cursor.getString(cursor.getColumnIndex(DB_ABSTRACTS.DBCourse.PASS_MARK_COLUMN))); } while (cursor.moveToNext()); } return cursor; }
/* GET A SINGLE COURSE */ public Course getCourse(long course_id) { try { this.open(); } catch (SQLException e) { e.printStackTrace(); } String where = DB_ABSTRACTS.DBCourse.KEY_ID + " = " + course_id; // SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); SimpleDateFormat timeFormat = new SimpleDateFormat("HH:mm"); Professor prof = new Professor(); Cursor cursor = database.query( DB_ABSTRACTS.DBTasks.DATABASE_TABLE, allColumns, where, null, null, null, null); Course course = new Course(); course.setId(cursor.getInt(cursor.getColumnIndex(DB_ABSTRACTS.DBCourse.KEY_ID))); course.setName(cursor.getString(cursor.getColumnIndex(DB_ABSTRACTS.DBCourse.NAME_COLUMN))); prof.setProfessor_name( cursor.getString(cursor.getColumnIndex(DB_ABSTRACTS.DBCourse.PROFESSOR_COLUMN))); course.setProfessor(prof); course.setSemester( cursor.getString(cursor.getColumnIndex(DB_ABSTRACTS.DBCourse.SEMESTER_COLUMN))); course.setRoom(cursor.getString(cursor.getColumnIndex(DB_ABSTRACTS.DBCourse.ROOM_COLUMN))); course.setPassed(cursor.getInt(cursor.getColumnIndex(DB_ABSTRACTS.DBCourse.PASSED_COLUMN))); return course; }
/* GET COURSES WITH ALL COLUMNS */ public Cursor getAllCourseData() { database = course_dbHelper.getWritableDatabase(); Cursor cursor = database.query( DB_ABSTRACTS.DBCourse.DATABASE_TABLE, allColumns, null, null, null, null, DB_ABSTRACTS.DBCourse.NAME_COLUMN + " ASC"); Professor prof = new Professor(); if (cursor.moveToFirst()) { do { Course course = new Course(); course.setId(cursor.getInt(cursor.getColumnIndex(DB_ABSTRACTS.DBCourse.KEY_ID))); course.setName(cursor.getString(cursor.getColumnIndex(DB_ABSTRACTS.DBCourse.NAME_COLUMN))); prof.setProfessor_name( cursor.getString(cursor.getColumnIndex(DB_ABSTRACTS.DBCourse.PROFESSOR_COLUMN))); course.setProfessor(prof); course.setSemester( cursor.getString(cursor.getColumnIndex(DB_ABSTRACTS.DBCourse.SEMESTER_COLUMN))); course.setRoom(cursor.getString(cursor.getColumnIndex(DB_ABSTRACTS.DBCourse.ROOM_COLUMN))); course.setPassed(cursor.getInt(cursor.getColumnIndex(DB_ABSTRACTS.DBCourse.PASSED_COLUMN))); } while (cursor.moveToNext()); } return cursor; }