@Override public long createOrUpdateObject(Object object) { CompanyMedia companyMedia = (CompanyMedia) object; long id = companyMedia.getId(); String type = companyMedia.getType(); String url = companyMedia.getUrl(); long parentId = companyMedia.getParentId(); ContentValues values = new ContentValues(); values.put(DBSQLiteHelper.COLUMN_COMPANY_MEDIA_TYPE, type); values.put(DBSQLiteHelper.COLUMN_COMPANY_MEDIA_URL, url); values.put(DBSQLiteHelper.COLUMN_COMPANY_MEDIA_PARENT_ID, parentId); if (super.isRowExists(id)) { /* Update the Row if it is exists */ super.updateRow(id, values); } else { values.put(DBSQLiteHelper.COLUMN_ID, id); super.insertRow(values); } return id; }
/** * Deletes the Row with the Given Row ID * * @param rowId ID of the ROW that will be deleted */ public void deleteSubMediasWithParentId(long parentId) { super.getDatabaseInstance() .delete( tableName, DBSQLiteHelper.COLUMN_COMPANY_MEDIA_PARENT_ID + " = ? ", new String[] {"" + parentId}); }