/** * ======================================================================== public void addTrip() * ------------------------------------------------------------------------ */ public void addTrip(Trip trip) { SQLiteDatabase db = getWritableDatabase(); ContentValues values = new ContentValues(); values.put(ORIGIN_LATITUDE_KEY, trip.getOrigin().getLatitude()); values.put(ORIGIN_LONGITUDE_KEY, trip.getOrigin().getLongitude()); values.put(ORIGIN_TIMESTAMP_KEY, trip.getOrigin().getTime()); values.put(DESTINATION_LATITUDE_KEY, trip.getDestination().getLatitude()); values.put(DESTINATION_LONGITUDE_KEY, trip.getDestination().getLongitude()); values.put(DESTINATION_TIMESTAMP_KEY, trip.getDestination().getTime()); db.insert(TABLE_NAME, null, values); db.close(); db = null; }
/** * ======================================================================== public void * exportToFile ------------------------------------------------------------------------ */ public void exportToFile() { LogFile log = new LogFile(TRIP_LOG_FILENAME, false); // Write header log.write( "origin_latitude,origin_longitude,destination_latitude,destination_longitude,timesTraveled"); ArrayList<Trip> tripList = getTrips(); for (Trip trip : tripList) { log.write( String.format( "%f,%f,%f,%f,%d", trip.getOrigin().getLatitude(), trip.getOrigin().getLongitude(), trip.getDestination().getLatitude(), trip.getDestination().getLongitude(), trip.getTimesTraveled())); } log = null; }