Ejemplo n.º 1
0
  /**
   * Convert an event to a ContentValues in order to store it into the database.
   *
   * @param e The event to be converted.
   * @return The ContentValues obtained by this event.
   */
  private ContentValues eventToValues(Event e) {
    ContentValues values = new ContentValues();
    values.put(H.E_NAME, e.getName());
    values.put(H.E_OWNER, e.getOwner());
    values.put(H.E_STIME, e.getStartTime());
    values.put(H.E_ETIME, e.getEndTime());
    values.put(H.E_SDATE, e.getStartDate());
    values.put(H.E_EDATE, e.getEndDate());
    char[] days = e.getDays();
    for (int i = 0; i < 7; i++) {
      values.put(H.E_DAYS[i + 1], days[i] == '*' ? 0 : 1);
    }

    return values;
  }
Ejemplo n.º 2
0
  /**
   * Update an existed event.
   *
   * @param e The event to be updated.
   */
  public void updateEvent(Event e) {
    long eventId = e.getId();

    database.update(H.TABLE_EVENTS, eventToValues(e), H.E_ID + " = " + eventId, null);
  }
Ejemplo n.º 3
0
 /**
  * Delete an Event in the database.
  *
  * @param e The event to be deleted
  */
 public void deleteEvent(Event e) {
   long id = e.getId();
   System.out.println("Event deleted with id: " + id);
   database.delete(H.TABLE_EVENTS, H.E_ID + " = " + id, null);
 }