/** * 插入一条专辑数据 * * @param pDiggerAlbum 专辑对象 */ public void insert(DiggerAlbum pDiggerAlbum) { try { mDiggerAlbumDao.create(pDiggerAlbum); } catch (SQLException e) { e.printStackTrace(); Logger.e( TAG, "insert " + DiggerAlbum.class.getSimpleName() + " failure >>>" + e.getMessage()); } }
/** * 按照专辑id 来查询指定专辑 * * @param id 专辑id * @return 指定id的专辑对象 */ public DiggerAlbum queryById(String id) { try { return mDiggerAlbumDao.queryForId(id); } catch (SQLException e) { e.printStackTrace(); Logger.e( TAG, "queryById " + DiggerAlbum.class.getSimpleName() + " failure >>>" + e.getMessage()); } return null; }
public DiggerAlbumDao(Context pContext) { mContext = pContext; mDbHelper = DatabaseHelper.getHelper(pContext); try { mDiggerAlbumDao = mDbHelper.getDao(DiggerAlbum.class); } catch (SQLException e) { e.printStackTrace(); Logger.e(TAG, "dao failure >>>" + e.getMessage()); } }
/** * 插入一个集合专辑数据 * * @param pAlbumList 专辑对象集合 */ public void insertList(List<DiggerAlbum> pAlbumList) { try { if (!TextUtil.isListEmpty(pAlbumList)) { for (DiggerAlbum album : pAlbumList) { insert(album); } } } catch (Exception e) { e.printStackTrace(); Logger.e( TAG, "insert " + DiggerAlbum.class.getSimpleName() + " failure >>>" + e.getMessage()); } }
/** * 更新专辑信息 * * @param pDiggerAlbum 要修改的专辑对象 */ public void update(DiggerAlbum pDiggerAlbum) { if (pDiggerAlbum != null) { DiggerAlbum existAlbum = queryById(pDiggerAlbum.getAlbum_id()); if (existAlbum != null) { try { mDiggerAlbumDao.update(pDiggerAlbum); } catch (SQLException e) { e.printStackTrace(); Logger.e( TAG, "update " + DiggerAlbum.class.getSimpleName() + " failure >>>" + e.getMessage()); } } } }