public long addWorkout(Workout workout) { ContentValues values = new ContentValues(); values.put(DatabaseHelper.FIELD_NAME, workout.getName()); values.put(DatabaseHelper.FIELD_WORKOUT_DURATION, workout.getWorkoutDuration()); values.put(DatabaseHelper.FIELD_REST_DURATION, workout.getRestDuration()); values.put(DatabaseHelper.FIELD_REPETITIONS, workout.getRepetitions()); values.put(DatabaseHelper.FIELD_ENABLED, workout.isEnabled() ? 1 : 0); return db.insert(DatabaseHelper.TABLE_WORKOUTS, null, values); }
public void updateWorkout(Workout workout) { if (workout == null) return; ContentValues values = new ContentValues(); values.put(DatabaseHelper.FIELD_NAME, workout.getName()); values.put(DatabaseHelper.FIELD_WORKOUT_DURATION, workout.getWorkoutDuration()); values.put(DatabaseHelper.FIELD_REST_DURATION, workout.getRestDuration()); values.put(DatabaseHelper.FIELD_REPETITIONS, workout.getRepetitions()); values.put(DatabaseHelper.FIELD_ENABLED, workout.isEnabled() ? 1 : 0); db.update( DatabaseHelper.TABLE_WORKOUTS, values, DatabaseHelper.FIELD_ID + "=" + workout.getId(), null); }
public void deleteWorkout(Workout workout) { if (workout == null) return; db.delete(DatabaseHelper.TABLE_WORKOUTS, DatabaseHelper.FIELD_ID + "=" + workout.getId(), null); }