public int updateCourse(Course course) { try { this.open(); } catch (SQLException e) { e.printStackTrace(); } ContentValues values = new ContentValues(); values.put(DB_ABSTRACTS.DBCourse.NAME_COLUMN, course.getName()); values.put(DB_ABSTRACTS.DBCourse.ROOM_COLUMN, course.getRoom()); values.put(DB_ABSTRACTS.DBCourse.PROFESSOR_COLUMN, course.getProfessor().getProfessor_name()); values.put(DB_ABSTRACTS.DBCourse.SEMESTER_COLUMN, course.getSemester()); values.put(DB_ABSTRACTS.DBCourse.PASSED_COLUMN, course.getPassed()); values.put(DB_ABSTRACTS.DBCourse.PASS_MARK_COLUMN, course.getPass_mark()); String where = DB_ABSTRACTS.DBCourse.KEY_ID + " = ?"; // update row return database.update( DB_ABSTRACTS.DBCourse.DATABASE_TABLE, values, where, new String[] {String.valueOf(course.getId())}); }
/* INSERT INTO THE DATABASE */ public long createCourse(Course course, Professor prof) { try { this.open(); } catch (SQLException e) { e.printStackTrace(); } ContentValues values = new ContentValues(); values.put(DB_ABSTRACTS.DBCourse.NAME_COLUMN, course.getName()); values.put(DB_ABSTRACTS.DBCourse.ROOM_COLUMN, course.getRoom()); values.put(DB_ABSTRACTS.DBCourse.PROFESSOR_COLUMN, prof.getProfessor_name()); values.put(DB_ABSTRACTS.DBCourse.SEMESTER_COLUMN, course.getSemester()); values.put(DB_ABSTRACTS.DBCourse.PASSED_COLUMN, course.getPassed()); values.put(DB_ABSTRACTS.DBCourse.PASS_MARK_COLUMN, course.getPass_mark()); long id = database.insert(DB_ABSTRACTS.DBCourse.DATABASE_TABLE, null, values); return id; }