private ContentValues getContentValues(Pursuit pursuit) { ContentValues pursuitValues = new ContentValues(); if (pursuit.getName() != null) pursuitValues.put(DatabaseHelper.COLUMN_PURSUIT_NAME, pursuit.getName()); if (pursuit.getStatedType() != null) pursuitValues.put(DatabaseHelper.COLUMN_PURSUIT_TYPE, pursuit.getStatedType().getIntCode()); if (pursuit.getIdealScore() != null) pursuitValues.put(DatabaseHelper.COLUMN_IDEAL_SCORE, pursuit.getIdealScore().getId()); return pursuitValues; }
public void insertPursuit(Pursuit pursuit) { // TODO // Score idealScore = pursuit.getIdealScore(); // scoreDAO.insertScore(idealScore); ContentValues pursuitValues = getContentValues(pursuit); long insertId = database.insert(DatabaseHelper.PURSUIT_TABLE, null, pursuitValues); if (insertId == -1) { Log.e( this.getClass().getSimpleName(), "There was an error inserting " + pursuit.getName() + " into the database"); } else { pursuit.setId(insertId); Log.d(this.getClass().getSimpleName(), "Pursuit with id " + insertId + " added to database"); } }