public Notification(final ContentValues values) { time = values.getAsLong(Columns.TIME); permanent = 1 == values.getAsLong(Columns.PERMANENT); taskID = values.getAsLong(Columns.TASKID); repeats = values.getAsLong(Columns.REPEATS); locationName = values.getAsString(Columns.LOCATIONNAME); latitude = values.getAsDouble(Columns.LATITUDE); longitude = values.getAsDouble(Columns.LONGITUDE); radius = values.getAsDouble(Columns.RADIUS); }
public static Movie fromContentValues(ContentValues values) { Movie m = new Movie(); m.id = values.getAsLong(MovieContract.MovieEntry._ID); m.title = values.getAsString(MovieContract.MovieEntry.COLUMN_NAME_TITLE); m.overview = values.getAsString(MovieContract.MovieEntry.COLUMN_OVERVIEW); m.posterUrl = values.getAsString(MovieContract.MovieEntry.COLUMN_POSTER_PATH); m.releaseDate = values.getAsString(MovieContract.MovieEntry.COLUMN_RELEASE_DATE); m.rating = values.getAsDouble(MovieContract.MovieEntry.COLUMN_VOTE_AVERAGE); m.popularity = values.getAsDouble(MovieContract.MovieEntry.COLUMN_POPULARITY); m.isFavorite = values.getAsInteger(MovieContract.MovieEntry.COLUMN_FAVORITE) == 0 ? false : true; return m; }
/** * Initialize a FillUp based on a set of ContentValues. This is likely to be used when saving a * new FillUp into the database. By initializing the data before sending, we can perform sanity * checks to make sure that there isn't anything weird with the data before we commit it to the * database. * * @param values A ContentValues mapping of the data to load. */ public FillUp(ContentValues values) { this((CalculationEngine) null); Double price = values.getAsDouble(PRICE); if (price != null) { setPrice(price); } Double odometer = values.getAsDouble(ODOMETER); if (odometer != null) { setOdometer(odometer); } Long time = values.getAsLong(DATE); if (time != null) { setDate(time); } Double amount = values.getAsDouble(AMOUNT); if (amount != null) { setAmount(amount); } Double latitude = values.getAsDouble(LATITUDE); if (latitude != null) { setLatitude(latitude); } Double longitude = values.getAsDouble(LONGITUDE); if (longitude != null) { setLongitude(longitude); } String comment = values.getAsString(COMMENT); if (comment != null) { setComment(comment); } Long vehicleId = values.getAsLong(VEHICLE_ID); if (vehicleId != null) { setVehicleId(vehicleId); } Integer isPartial = values.getAsInteger(PARTIAL); if (isPartial != null) { setPartial(isPartial == 1); } }
@Override public Produto contentValuesParaEntidade(ContentValues contentValues) { Produto pro = new Produto(); pro.setId(contentValues.getAsInteger(COLUNA_ID)); pro.setNome(contentValues.getAsString(COLUNA_NOME)); pro.setValor(contentValues.getAsDouble(COLUNA_VALOR)); pro.setId_fornecedor(contentValues.getAsInteger(COLUNA_ID_FORNECEDOR)); return pro; }
/* Students: This code will allow the FetchWeatherTask to continue to return the strings that the UX expects so that we can continue to test the application even once we begin using the database. */ String[] convertContentValuesToUXFormat(Vector<ContentValues> cvv) { // return strings to keep UI functional for now String[] resultStrs = new String[cvv.size()]; for (int i = 0; i < cvv.size(); i++) { ContentValues weatherValues = cvv.elementAt(i); String highAndLow = formatHighLows( weatherValues.getAsDouble(WeatherEntry.COLUMN_MAX_TEMP), weatherValues.getAsDouble(WeatherEntry.COLUMN_MIN_TEMP)); resultStrs[i] = getReadableDateString(weatherValues.getAsLong(WeatherEntry.COLUMN_DATE)) + " - " + weatherValues.getAsString(WeatherEntry.COLUMN_SHORT_DESC) + " - " + highAndLow; } return resultStrs; }
@Override public Double getAsDouble(String key) { return contentValues.getAsDouble(key); }
public Double getAsDouble(String key, Double def) { return contentValues.containsKey(key) && contentValues.get(key) != null ? contentValues.getAsDouble(key) : def; }
/** * (non-Javadoc) * * @see android.content.ContentProvider#insert(android.net.Uri, android.content.ContentValues) */ @Override public Uri insert(Uri uri, ContentValues values) { // Log.d( TAG, "insert on "+uri ); Uri insertedUri = null; int match = GPStrackingProvider.sURIMatcher.match(uri); List<String> pathSegments = null; long trackId; long segmentId; long waypointId = -1; switch (match) { case WAYPOINTS: pathSegments = uri.getPathSegments(); trackId = Integer.parseInt(pathSegments.get(1)); segmentId = Integer.parseInt(pathSegments.get(3)); Location loc = new Location(TAG); Double latitude = values.getAsDouble(Waypoints.LATITUDE); Double longitude = values.getAsDouble(Waypoints.LONGITUDE); Long time = values.getAsLong(Waypoints.TIME); Float speed = values.getAsFloat(Waypoints.SPEED); if (time == null) { time = System.currentTimeMillis(); } if (speed == null) { speed = 0f; } loc.setLatitude(latitude); loc.setLongitude(longitude); loc.setTime(time); loc.setSpeed(speed); if (values.containsKey(Waypoints.ACCURACY)) { loc.setAccuracy(values.getAsFloat(Waypoints.ACCURACY)); } if (values.containsKey(Waypoints.ALTITUDE)) { loc.setAltitude(values.getAsDouble(Waypoints.ALTITUDE)); } if (values.containsKey(Waypoints.BEARING)) { loc.setBearing(values.getAsFloat(Waypoints.BEARING)); } waypointId = this.mDbHelper.insertWaypoint(trackId, segmentId, loc); // Log.d( TAG, "Have inserted to segment "+segmentId+" with waypoint "+waypointId // ); insertedUri = ContentUris.withAppendedId(uri, waypointId); break; case SEGMENTS: pathSegments = uri.getPathSegments(); trackId = Integer.parseInt(pathSegments.get(1)); segmentId = this.mDbHelper.toNextSegment(trackId); insertedUri = ContentUris.withAppendedId(uri, segmentId); break; case TRACKS: String name = (values == null) ? "" : values.getAsString(Tracks.NAME); trackId = this.mDbHelper.toNextTrack(name); insertedUri = ContentUris.withAppendedId(uri, trackId); break; default: Log.e(GPStrackingProvider.LOG_TAG, "Unable to match the URI:" + uri.toString()); insertedUri = null; break; } return insertedUri; }