<T> void deleteByPaymentGroup(Dao<T, Long> dao, PaymentGroup group) { DeleteBuilder<T, Long> builder = dao.deleteBuilder(); try { builder.where().eq("paymentGroup_id", group.id); dao.delete(builder.prepare()); } catch (SQLException e) { Logger.e(e); } }
public void clearLocal(Dao<NoiseEntry, Long> noiseDao, Dao<CommentEntry, Long> commDao) { this.is_local = false; this.my_capacity = 0.0; this.my_crowd = 0.0; this.my_productivity = 0.0; this.my_n_surveys = 0; try { // delete local noise data DeleteBuilder<NoiseEntry, Long> deletion = noiseDao.deleteBuilder(); deletion.where().eq(NoiseEntry.COLUMN_NAME_IS_LOCAL, Boolean.TRUE); noiseDao.delete(deletion.prepare()); // delete local comment data DeleteBuilder<CommentEntry, Long> deletion2 = commDao.deleteBuilder(); deletion2.where().eq(CommentEntry.COLUMN_NAME_IS_LOCAL, Boolean.TRUE); commDao.delete(deletion2.prepare()); } catch (SQLException e) { e.printStackTrace(); } }
@Override public int delete(int id) { final String methodName = "delete"; Log.i(TAG, "START: " + methodName); long time = System.currentTimeMillis(); int rows = 0; try { DeleteBuilder<Route, Integer> db = routetDao.deleteBuilder(); db.where().eq("id", id); rows = routetDao.delete(db.prepare()); } catch (SQLException e) { Log.e(TAG, methodName + " - blad przy usuwaniu trasy. " + e.getMessage()); e.printStackTrace(); } Log.i(TAG, "END: " + methodName + " TIME: " + (System.currentTimeMillis() - time)); return rows; }