예제 #1
0
  public List<PresencePublicity> getAllPresencePublicityGroupCategory() {
    List<PresencePublicity> publicities = new ArrayList<PresencePublicity>();
    String selectQuery =
        "SELECT  * FROM " + TABLE_PRESENCE_PUBLICITY + " GROUP BY " + KEY_CATEGORY_ID;

    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 {
        PresencePublicity pd = new PresencePublicity();
        pd.setId(c.getInt((c.getColumnIndex(KEY_ID))));
        pd.setPublicity_id((c.getInt(c.getColumnIndex(KEY_PUBLICITY_ID))));
        pd.setCategory_id((c.getInt(c.getColumnIndex(KEY_CATEGORY_ID))));
        pd.setStore_id((c.getInt(c.getColumnIndex(KEY_STORY_ID))));
        pd.setFound((c.getInt(c.getColumnIndex(KEY_FOUND))));
        pd.setVisible((c.getInt(c.getColumnIndex(KEY_VISIBLE))));
        pd.setLayout_correcto((c.getInt(c.getColumnIndex(KEY_LAYOUT_CORRECT))));
        // adding to todo list
        publicities.add(pd);
      } while (c.moveToNext());
    }
    return publicities;
  }
예제 #2
0
  public long createPresensePublicity(PresencePublicity presencePublicity) {
    SQLiteDatabase db = this.getWritableDatabase();

    ContentValues values = new ContentValues();

    // values.put(KEY_ID, product.getId());
    values.put(KEY_STORY_ID, presencePublicity.getStore_id());
    values.put(KEY_CATEGORY_ID, presencePublicity.getCategory_id());
    values.put(KEY_PUBLICITY_ID, presencePublicity.getPublicity_id());
    values.put(KEY_FOUND, presencePublicity.getFound());
    values.put(KEY_VISIBLE, presencePublicity.getVisible());
    values.put(KEY_LAYOUT_CORRECT, presencePublicity.getLayout_correcto());

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

    // long todo_id = presenseProduct.getId();
    return id;
  }