예제 #1
0
 /** 修改专业 */
 public boolean modifyMajor(Major major, String id) {
   ContentValues values = new ContentValues();
   values.put("major_id", major.getMajor_id());
   values.put("major_name", major.getMajor_name());
   long l = db.update("major", values, "major_id=?", new String[] {id});
   return l == 1;
 }
예제 #2
0
 /** @param major 保存major到数据库 */
 public boolean saveMajor(Major major) {
   if (major != null) {
     ContentValues values = new ContentValues();
     values.put("major_id", major.getMajor_id());
     values.put("major_name", major.getMajor_name());
     long l = db.insert("major", null, values);
     if (l == -1) {
       return false;
     } else {
       return true;
     }
   }
   return false;
 }
예제 #3
0
 /** @return 返回存有所有Major的List */
 public List<Major> getMajor() {
   List<Major> list = new ArrayList<Major>();
   Cursor cursor = db.query("major", null, null, null, null, null, null);
   while (cursor.moveToNext()) {
     Major major = new Major();
     major.setMajor_id(cursor.getString(cursor.getColumnIndex("major_id")));
     major.setMajor_name(cursor.getString(cursor.getColumnIndex("major_name")));
     list.add(major);
   }
   if (cursor != null) {
     cursor.close();
   }
   return list;
 }