Example #1
0
  /**
   * Insert or update this object using the specified database connection.
   *
   * @param db The database connection to use.
   * @return The primary key of the inserted item (if object was transient), or -1 if an update was
   *     performed.
   */
  public int save(SQLiteDatabase db) {
    EntityMapping mapping = getEntityMappingEnsureSchema(db);

    int result = -1;

    if (mTransient) {
      result = mapping.insert(db, this);
      mTransient = false;
    } else {
      mapping.update(db, this);
    }

    return result;
  }