/** * Convert a Person object to a ContentValues object in order to store it into the database. * * @param p The person to convert * @return The converted value */ private ContentValues personToValue(Person p) { ContentValues values = new ContentValues(); values.put(H.P_NAME, p.getName()); values.put(H.P_PHONE, p.getPhoneNumber()); return values; }
/** * Update an existed person. * * @param p The person to be updated. */ public void updatePerson(Person p) { long personId = p.getId(); database.update(H.TABLE_PERSONS, personToValue(p), H.P_ID + " = " + personId, null); }
/** * Delete a Person in the database. * * @param p The person to be deleted */ public void deletePerson(Person p) { long id = p.getId(); database.delete(H.TABLE_PERSONS, H.P_ID + " = " + id, null); database.delete(H.TABLE_EVENTS, H.E_OWNER + " = " + id, null); }