private void add() { /*SQLiteDatabase db = mDbHelper.getWritableDatabase(); CustomEngineParcelable parcelable = getParcelable(); parcelable.data.id = CustomEngine.getAvailableId(); mData.add(parcelable.data); ContentValues values = new ContentValues(); values.put(CustomEngineTable.COLUMN_ID, parcelable.data.id); values.put(CustomEngineTable.COLUMN_DATA, ParcelableUtils.marshall(parcelable)); db.insert(CustomEngineTable.TABLE_NAME, null, values);*/ CustomEngineParcelable parcelable = new CustomEngineParcelable(); parcelable.data = getData(); parcelable.data.setId(CustomEngine.getAvailableId()); parcelable.data.setEnabled(1); CustomEngine.addEngineToDb(this, parcelable, parcelable.data.getId()); CustomEngine.addEngineToList(parcelable.data); EditSitesActivity.getAdapter(this).notifyItemInserted(mData.size() - 1); EditSitesActivity.getAdapter(this).notifyItemChanged(mData.size() - 2); }
private void modify() { SQLiteDatabase db = mDbHelper.getReadableDatabase(); CustomEngineParcelable parcelable = new CustomEngineParcelable(); parcelable.data = getData(); ContentValues values = new ContentValues(); values.put(CustomEngineTable.COLUMN_DATA, ParcelableUtils.marshall(parcelable)); String selection = CustomEngineTable.COLUMN_ID + " LIKE ?"; String[] selectionArgs = {String.valueOf(mItem.getId())}; db.update(CustomEngineTable.TABLE_NAME, values, selection, selectionArgs); mItem.setName(parcelable.data.getName()); mItem.setUpload_url(parcelable.data.getUpload_url()); mItem.setPost_file_key(parcelable.data.getPost_file_key()); mItem.setResult_open_action(parcelable.data.getResult_open_action()); mItem.post_text_key = parcelable.data.post_text_key; mItem.post_text_value = parcelable.data.post_text_value; mItem.post_text_type = parcelable.data.post_text_type; EditSitesActivity.getAdapter(this).notifyItemChanged(mLocation); }