コード例 #1
0
  /**
   * Update Audit
   *
   * @param audit
   * @return
   */
  public int updateAudit(Audit audit) {
    SQLiteDatabase db = this.getWritableDatabase();

    ContentValues values = new ContentValues();
    values.put(KEY_ID, audit.getId());
    values.put(KEY_NAME, audit.getName());
    values.put(KEY_STORY_ID, audit.getStore_id());
    values.put(KEY_SCORE, audit.getScore());

    // updating row
    return db.update(
        TABLE_AUDITS, values, KEY_ID + " = ?", new String[] {String.valueOf(audit.getId())});
  }
コード例 #2
0
  public Audit getAudit(long id) {
    SQLiteDatabase db = this.getReadableDatabase();
    String selectQuery = "SELECT  * FROM " + TABLE_AUDITS + " WHERE " + KEY_ID + " = " + id;
    Log.e(LOG, selectQuery);
    Cursor c = db.rawQuery(selectQuery, null);
    if (c != null) c.moveToFirst();
    Audit pd = new Audit();
    pd.setId(c.getInt(c.getColumnIndex(KEY_ID)));
    pd.setName(c.getString(c.getColumnIndex(KEY_NAME)));
    pd.setScore((c.getInt(c.getColumnIndex(KEY_SCORE))));
    pd.setStore_id((c.getInt(c.getColumnIndex(KEY_STORY_ID))));

    return pd;
  }
コード例 #3
0
  /**
   * Create Audit
   *
   * @param audit
   * @return
   */
  public long createAudit(Audit audit) {
    SQLiteDatabase db = this.getWritableDatabase();

    ContentValues values = new ContentValues();

    values.put(KEY_ID, audit.getId());
    values.put(KEY_NAME, audit.getName());
    values.put(KEY_STORY_ID, audit.getStore_id());
    values.put(KEY_SCORE, audit.getScore());

    // insert row
    // long todo_id = db.insert(TABLE_PEDIDO, null, values);
    db.insert(TABLE_AUDITS, null, values);

    long todo_id = audit.getId();
    return todo_id;
  }
コード例 #4
0
  /**
   * .Return List Audits
   *
   * @return
   */
  public List<Audit> getAllAudits() {
    List<Audit> audit = new ArrayList<Audit>();
    String selectQuery = "SELECT  * FROM " + TABLE_AUDITS;

    Log.e(LOG, selectQuery);

    SQLiteDatabase db = this.getReadableDatabase();
    Cursor c = db.rawQuery(selectQuery, null);

    // looping through all rows and adding to list
    if (c.moveToFirst()) {
      do {
        Audit pd = new Audit();
        pd.setId(c.getInt((c.getColumnIndex(KEY_ID))));
        pd.setName((c.getString(c.getColumnIndex(KEY_NAME))));
        pd.setStore_id((c.getInt(c.getColumnIndex(KEY_STORY_ID))));
        pd.setScore((c.getLong(c.getColumnIndex(KEY_SCORE))));
        // adding to todo list
        audit.add(pd);
      } while (c.moveToNext());
    }
    return audit;
  }