/**
  * @param id Id of the note to update
  * @param title Title to update to
  * @param text Text to update to
  * @param l Location to update to
  * @param path ImagePath to update to
  * @param alarm Alarm to update to
  * @param ncat Category to update to
  * @param adr Address to update to
  * @return true if database was updated, false otherwise
  */
 public boolean updateNote(
     int id,
     String title,
     String text,
     Location l,
     String path,
     String alarm,
     NoteCategory ncat,
     String adr) {
   // Set default values to prevent null in database
   if (title == null) title = "";
   if (text == null) text = "";
   if (l == null) l = new Location(0.0, 0.0);
   if (path == null) path = "";
   if (alarm == null) alarm = "";
   if (ncat == null) ncat = NoteCategory.NO_CATEGORY;
   if (adr == null) adr = "";
   ContentValues cv = new ContentValues();
   cv.put(KEY_TITLE, title);
   cv.put(KEY_TEXT, text);
   cv.put(KEY_LONGITUDE, l.getLongitude());
   cv.put(KEY_LATITUDE, l.getLatitude());
   cv.put(KEY_IMAGEPATH, path);
   cv.put(KEY_ALARM, alarm);
   cv.put(KEY_CATEGORY, ncat.ordinal());
   cv.put(KEY_ADDRESS, adr);
   boolean b = this.db.update(TABLE_NOTE, cv, ID + "=" + id, null) > 0;
   this.setChanged();
   this.notifyObservers(DatabaseUpdate.UPDATED_NOTE);
   return b;
 }
 /**
  * @param title Title of the note to insert
  * @param text Text of the note to insert
  * @param l Location of the note to insert
  * @param path ImagePath of the note to insert
  * @param alarm Alarm date of the note to insert
  * @param ncat Category of the note to insert
  * @param adr Address of the note to insert
  * @return Id or -1 if an error occurred
  */
 public long insertNote(
     String title,
     String text,
     Location l,
     String path,
     String alarm,
     NoteCategory ncat,
     String adr) {
   // Set default values to prevent null in database
   if (title == null) title = "";
   if (text == null) text = "";
   if (l == null) l = new Location(0.0, 0.0);
   if (path == null) path = "";
   if (alarm == null) alarm = "";
   if (ncat == null) ncat = NoteCategory.NO_CATEGORY;
   if (adr == null) adr = "";
   ContentValues cv = new ContentValues();
   cv.put(KEY_TITLE, title);
   cv.put(KEY_TEXT, text);
   cv.put(KEY_LONGITUDE, l.getLongitude());
   cv.put(KEY_LATITUDE, l.getLatitude());
   cv.put(KEY_IMAGEPATH, path);
   cv.put(KEY_ALARM, alarm);
   SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
   Date date = new Date();
   cv.put(KEY_DATE, dateFormat.format(date));
   cv.put(KEY_CATEGORY, ncat.ordinal());
   cv.put(KEY_ADDRESS, adr);
   cv.put(KEY_REQUEST_CODE, -1);
   long tmp = this.db.insert(TABLE_NOTE, null, cv);
   this.setChanged();
   this.notifyObservers(DatabaseUpdate.NEW_NOTE);
   return tmp;
 }
 /**
  * @param id Id of the note to update
  * @param l The Location object with the longitude and latitude to update to
  * @return true if database was updated, false otherwise
  */
 public boolean updateLocation(int id, Location l) {
   if (l == null) l = new Location(0.0, 0.0);
   ContentValues cv = new ContentValues();
   cv.put(KEY_LONGITUDE, l.getLongitude());
   cv.put(KEY_LATITUDE, l.getLatitude());
   boolean b = this.db.update(TABLE_NOTE, cv, ID + "=" + id, null) > 0;
   this.setChanged();
   this.notifyObservers(DatabaseUpdate.UPDATED_LOCATION);
   return b;
 }