예제 #1
0
 public int update(DBData dbData) {
   ContentValues values = new ContentValues();
   values.put(COLUMN_ID, dbData.getId());
   values.put(COLUMN_MEMO, dbData.getMemo());
   values.put(COLUMN_PRIORITY, dbData.getPriority());
   String whereClause = "id = " + dbData.getId();
   return db.update(TABLE_NAME, values, whereClause, null);
 }
예제 #2
0
 public DBData findById(int id) {
   String selection = "id = " + id;
   Cursor cursor = db.query(TABLE_NAME, COLUMNS, selection, null, null, null, null);
   while (cursor.moveToNext()) {
     DBData dbData = new DBData();
     dbData.setId(cursor.getInt(0));
     dbData.setMemo(cursor.getString(1));
     dbData.setPriority(cursor.getInt(2));
     return dbData;
   }
   return null;
 }
예제 #3
0
 public List<DBData> findAll() {
   List<DBData> dbDataList = new ArrayList<DBData>();
   Cursor cursor = db.query(TABLE_NAME, COLUMNS, null, null, null, null, COLUMN_ID);
   while (cursor.moveToNext()) {
     DBData dbData = new DBData();
     dbData.setId(cursor.getInt(0));
     dbData.setMemo(cursor.getString(1));
     dbData.setPriority(cursor.getInt(2));
     dbDataList.add(dbData);
   }
   return dbDataList;
 }
예제 #4
0
 public long insert(DBData dbData) {
   ContentValues values = new ContentValues();
   values.put(COLUMN_MEMO, dbData.getMemo());
   values.put(COLUMN_PRIORITY, dbData.getPriority());
   return db.insert(TABLE_NAME, null, values);
 }