public FunctionButton insert(FunctionButton btn) { SQLiteDatabase db = getWritableDatabase(); long id = db.insert(TABLE_FUNCBTNS, null, btn.getValues()); db.close(); btn.setId(id); return btn; }
public List<FunctionButton> get() { List<FunctionButton> btns = new LinkedList<FunctionButton>(); SQLiteDatabase db = getReadableDatabase(); Cursor c = db.query( TABLE_FUNCBTNS, null, null, null, null, null, FIELD_FUNCBTNS_SORTNUMBER + " ASC"); while (c.moveToNext()) { FunctionButton btn = new FunctionButton(); btn.setId(c.getLong(c.getColumnIndexOrThrow(FIELD_FUNCBTNS_ID))); btn.setName(c.getString(c.getColumnIndexOrThrow(FIELD_FUNCBTNS_NAME))); btn.setKeys(c.getString(c.getColumnIndexOrThrow(FIELD_FUNCBTNS_KEYS))); btn.setSortNumber(c.getInt(c.getColumnIndexOrThrow(FIELD_FUNCBTNS_SORTNUMBER))); btns.add(btn); } c.close(); db.close(); return btns; }