public List<BodyLogDto> findAll() { Cursor cursor = null; try { List<BodyLogDto> list = new ArrayList<BodyLogDto>(); cursor = db.query( BodyLog.TABLE_NAME, COLUMNS, null, null, null, null, BodyLog.Columns.USER_ID.column()); if (cursor.moveToFirst()) { do { list.add(BodyLog.convert(cursor)); } while (cursor.moveToNext()); } return list; } catch (SQLException e) { throw new DaoException(DaoException.Error.ERROR, e); } finally { if (cursor != null) { try { cursor.close(); } catch (SQLException e) { e.printStackTrace(); } } } }
public class BodyLogDao extends DaoBase { private static final String[] COLUMNS = { BodyLog.Columns.USER_ID.column(), BodyLog.Columns.HEIGHT.column(), BodyLog.Columns.WEIGHT.column(), BodyLog.Columns.BODY_FAT.column(), BodyLog.Columns.BODY_AGE.column(), BodyLog.Columns.BONE_DENSITY.column(), BodyLog.Columns.MEASURE_DATE.column(), BodyLog.Columns.RECDATE_TIME.column() }; public BodyLogDao(SQLiteDatabase db) { super(db); } public List<BodyLogDto> findAll() { Cursor cursor = null; try { List<BodyLogDto> list = new ArrayList<BodyLogDto>(); cursor = db.query( BodyLog.TABLE_NAME, COLUMNS, null, null, null, null, BodyLog.Columns.USER_ID.column()); if (cursor.moveToFirst()) { do { list.add(BodyLog.convert(cursor)); } while (cursor.moveToNext()); } return list; } catch (SQLException e) { throw new DaoException(DaoException.Error.ERROR, e); } finally { if (cursor != null) { try { cursor.close(); } catch (SQLException e) { e.printStackTrace(); } } } } }