예제 #1
0
  public long create(ItemVO vo, int idFather) {
    SQLiteDatabase sqLiteDatabase = mDatabaseHelper.getWritableDatabase();

    ContentValues values = DatabaseTableItem.translate(vo, idFather);

    long id = sqLiteDatabase.insert(DatabaseTableItem.TABLE_NAME, null, values);

    sqLiteDatabase.close();

    return id;
  }
예제 #2
0
  public boolean update(ItemVO vo, int idFather) {
    SQLiteDatabase sqLiteDatabase = mDatabaseHelper.getWritableDatabase();

    ContentValues values = DatabaseTableItem.translate(vo, idFather);

    int ack =
        sqLiteDatabase.update(
            DatabaseTableItem.TABLE_NAME,
            values,
            DatabaseTableItem.ID + " = ?",
            new String[] {String.valueOf(vo.getId())});

    sqLiteDatabase.close();

    return ack == 1;
  }