Exemplo n.º 1
0
  /**
   * Checks if this record has an id, if the id is present this record will be updated, if it is
   * null, it will be inserted instead, and the inserted id assigned to this one.
   *
   * @param context The context used to save the record.
   */
  public void save(Context context) {

    if (_id == null) {

      _id = CPOrm.insert(context, this);
    } else CPOrm.update(context, this);
  }
Exemplo n.º 2
0
  public <T> Uri getItemUri() {

    return ContentUris.withAppendedId(CPOrm.getItemUri(getClass()), getId());
  }
Exemplo n.º 3
0
  /** @see #save(Context) */
  public void save() {

    save(CPOrm.getApplicationContext());
  }
Exemplo n.º 4
0
 /** @see #findById(Context, Class, long) */
 public static <T> T findById(Class<T> object, long id) {
   return CPOrm.findByPrimaryKey(object, id);
 }
Exemplo n.º 5
0
 /**
  * Finds a record based on the id column
  *
  * @param context Current context
  * @param id the id of the record to find
  * @return The record, if found.
  */
 public static <T> T findById(Context context, Class<T> object, long id) {
   return CPOrm.findByPrimaryKey(context, object, id);
 }