public void updateKid(Kid kid) { // Lock it! mLock.lock(); try { startTransaction(); kidsTable.updateEntry(localDatabase, kid, kid.getId(), kidsTable.getMapper()); } catch (DBException e) { Logger.error(this, "Problems starting transaction"); } finally { endTransaction(); mLock.unlock(); } }
/** * Get the list of all kids * * @return List<Kid> */ public List<Kid> getKids() { // Lock it! mLock.lock(); try { startTransaction(); return kidsTable.getAllEntries(localDatabase, Kid.class, kidsTable.getMapper()); } catch (DBException e) { Logger.error(this, "Problems starting transaction"); } finally { endTransaction(); mLock.unlock(); } return null; }
/** * Add a new Kid * * @param kid * @return Kid */ public Kid addKid(final Kid kid) { // Lock it! mLock.lock(); try { startTransaction(); long id = kidsTable.insertEntry(localDatabase, kid, kidsTable.getMapper()); kid.setId(id); return kid; } catch (DBException e) { Logger.error(this, "Problems starting transaction"); } finally { endTransaction(); mLock.unlock(); } return null; }
/** * Get a kid by the given id * * @param kidId * @return Kid */ public Kid getKid(int kidId) { // Lock it! mLock.lock(); try { startTransaction(); Kid kid = new Kid(); kid = kidsTable.getEntry( localDatabase, kid, KidsTable.KID_ID, String.valueOf(kidId), kidsTable.getMapper()); return kid; } catch (DBException e) { Logger.error(this, "Problems starting transaction"); } finally { endTransaction(); mLock.unlock(); } return null; }
public void deleteKids() { // Lock it! mLock.lock(); try { startTransaction(); kidsTable.deleteAllEntries(localDatabase); } catch (DBException e) { Logger.error(this, "Problems starting transaction"); } finally { endTransaction(); mLock.unlock(); } }
/** * Delete Kid * * @param kid */ public void deleteKid(Kid kid) { // Lock it! mLock.lock(); try { startTransaction(); int deleted = kidsTable.deleteEntryWhere( localDatabase, KidsTable.KID_ID, String.valueOf(kid.getKidId())); Logger.debug("Deleted " + deleted + " kids "); } catch (DBException e) { Logger.error(this, "Problems starting transaction"); } finally { endTransaction(); mLock.unlock(); } }