예제 #1
0
  /*
   * Updating a User
   */
  public int updateProduct(Product product) {
    SQLiteDatabase db = this.getWritableDatabase();

    ContentValues values = new ContentValues();
    values.put(KEY_NAME, product.getName());
    values.put(KEY_CODE, product.getCode());
    values.put(KEY_COMPANY_ID, product.getCompany_id());
    values.put(KEY_IMAGEN, product.getImage());
    values.put(KEY_CATEGORY_ID, product.getCategory_id());
    values.put(KEY_CATEGORY_NAME, product.getCategory_name());

    // updating row
    return db.update(
        TABLE_PRODUCTS, values, KEY_ID + " = ?", new String[] {String.valueOf(product.getId())});
  }
예제 #2
0
  /*
   * Creating a PRODUCTS
   */
  public long createProduct(Product product) {
    SQLiteDatabase db = this.getWritableDatabase();

    ContentValues values = new ContentValues();

    values.put(KEY_ID, product.getId());
    values.put(KEY_NAME, product.getName());
    values.put(KEY_CODE, product.getCode());
    values.put(KEY_IMAGEN, product.getImage());
    values.put(KEY_COMPANY_ID, product.getCompany_id());
    values.put(KEY_CATEGORY_ID, product.getCategory_id());
    values.put(KEY_CATEGORY_NAME, product.getCategory_name());

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

    long todo_id = product.getId();
    return todo_id;
  }