Beispiel #1
0
  public void delete(Context aContext) {
    ShiftCalendarDbOpenHelper dbOpener = new ShiftCalendarDbOpenHelper(aContext);
    SQLiteDatabase db = dbOpener.getWritableDatabase();

    db.delete(TABLE_NAME, ID_COLUMN + "=" + getId(), null);
    db.delete(ShiftCalendar.TABLE_NAME, ShiftCalendar.SHIFT_ID_COLUMN + "=" + getId(), null);
    db.close();
    dbOpener.close();
  }
Beispiel #2
0
 public void save(Context aContext) {
   if (mSortOrder < 0) {
     mSortOrder = loadAll(aContext).size();
   }
   ShiftCalendarDbOpenHelper dbOpener = new ShiftCalendarDbOpenHelper(aContext);
   SQLiteDatabase db = dbOpener.getWritableDatabase();
   ContentValues contentValues = toContentValues();
   contentValues.remove(ID_COLUMN);
   if (getId() < 0) {
     mId = Long.valueOf(db.insert(TABLE_NAME, null, contentValues)).intValue();
   } else {
     Long.valueOf(db.update(TABLE_NAME, contentValues, ID_COLUMN + "=" + getId(), null))
         .intValue();
   }
   db.close();
   dbOpener.close();
 }