@Override public Fueling mapRow(Cursor cursor) { if (columnIndex == null || !columnIndex.matches(cursor)) { columnIndex = new ColumnIndexHolder(cursor); } Fueling f = new FuelingBean(); f.setId(cursor.getLong(columnIndex.ID)); f.setCost(cursor.getFloat(columnIndex.COST)); f.setDistance(cursor.getInt(columnIndex.DISTANCE)); f.setFilldate(new Date(cursor.getLong(columnIndex.FILLDATE))); f.setOdometer(cursor.getInt(columnIndex.ODOMETER)); f.setQuantity(cursor.getFloat(columnIndex.QUANTITY)); f.setFillup(cursor.getInt(columnIndex.FILLUP) != 0); return f; }
@Override public ContentValues extractValues(Fueling f) { ContentValues cv = new ContentValues(); cv.put(FuelingTable.VEHICLE_ID, f.getVehicleId()); cv.put(FuelingTable.FILLUP, f.isFillup() ? 1 : 0); cv.put(FuelingTable.COST, f.getCost()); cv.put(FuelingTable.DISTANCE, f.getDistance()); cv.put(FuelingTable.FILLDATE, f.getFilldate().getTime()); cv.put(FuelingTable.ODOMETER, f.getOdometer()); cv.put(FuelingTable.QUANTITY, f.getQuantity()); return cv; }