List of usage examples for android.content ContentValues put
public void put(String key, byte[] value)
From source file:edu.stanford.mobisocial.dungbeetle.Helpers.java
public static Uri addDynamicGroup(final Context c, final Uri uri) { Uri url = Uri.parse(DungBeetleContentProvider.CONTENT_URI + "/dynamic_groups"); ContentValues values = new ContentValues(); values.put("uri", uri.toString()); return c.getContentResolver().insert(url, values); }
From source file:edu.stanford.mobisocial.dungbeetle.Helpers.java
public static void updateLastPresence(final Context c, final Contact contact, final long time) { ContentValues values = new ContentValues(); values.put(Contact.LAST_PRESENCE_TIME, time); c.getContentResolver().update(Uri.parse(DungBeetleContentProvider.CONTENT_URI + "/contacts"), values, "_id=?", new String[] { String.valueOf(contact.id) }); }
From source file:edu.stanford.mobisocial.dungbeetle.Helpers.java
public static void insertSubscriber(final Context c, Long contactId, String feedName) { ContentValues values = new ContentValues(); values.put(Subscriber.CONTACT_ID, contactId); values.put("feed_name", feedName); Uri url = Uri.parse(DungBeetleContentProvider.CONTENT_URI + "/subscribers"); c.getContentResolver().insert(url, values); }
From source file:edu.stanford.mobisocial.dungbeetle.Helpers.java
public static Uri insertContact(final Context c, String pubKeyStr, String name, String email) { ContentValues values = new ContentValues(); values.put(Contact.PUBLIC_KEY, pubKeyStr); values.put(Contact.NAME, name);//from ww w . ja va2 s . c om values.put(Contact.EMAIL, email); Uri url = Uri.parse(DungBeetleContentProvider.CONTENT_URI + "/contacts"); return c.getContentResolver().insert(url, values); }
From source file:edu.stanford.mobisocial.dungbeetle.Helpers.java
public static Uri insertGroup(final Context c, String groupName, String dynUpdateUri, String feedName) { assert (groupName != null && dynUpdateUri != null && feedName != null); ContentValues values = new ContentValues(); values.put(Group.NAME, groupName); values.put(Group.DYN_UPDATE_URI, dynUpdateUri); values.put(Group.FEED_NAME, feedName); return c.getContentResolver().insert(Uri.parse(DungBeetleContentProvider.CONTENT_URI + "/groups"), values); }
From source file:com.cloudmine.api.db.RequestDBObject.java
private static ContentValues headerToContentValues(Header header) { ContentValues headerValues = new ContentValues(); if (header == null) { return headerValues; }/*from w ww . j a v a 2 s . c o m*/ headerValues.put(KEY_HEADER_NAME, header.getName()); headerValues.put(KEY_HEADER_VALUE, header.getValue()); return headerValues; }
From source file:edu.stanford.mobisocial.dungbeetle.Helpers.java
public static void insertGroupMember(final Context c, final long groupId, final long contactId, final String idInGroup) { Uri url = Uri.parse(DungBeetleContentProvider.CONTENT_URI + "/group_members"); ContentValues values = new ContentValues(); values.put(GroupMember.GROUP_ID, groupId); values.put(GroupMember.CONTACT_ID, contactId); values.put(GroupMember.GLOBAL_CONTACT_ID, idInGroup); c.getContentResolver().insert(url, values); }
From source file:edu.mit.mobile.android.locast.data.TaggableItem.java
/** * Sets the tags of a given prefix for the given item. Any existing tags using the given prefix will be deleted. * @param cr/*from w ww. ja v a2 s .c o m*/ * @param item * @param tags * @param prefix */ public static void putTags(ContentResolver cr, Uri item, Collection<String> tags, String prefix) { final ContentValues cv = new ContentValues(); cv.put(Tag.PATH, TaggableItem.toListString(addPrefixToTags(prefix, tags))); cv.put(CV_TAG_PREFIX, prefix); cr.update(Uri.withAppendedPath(item, Tag.PATH), cv, null, null); }
From source file:edu.stanford.mobisocial.dungbeetle.Helpers.java
/** * Handle a group invite. (user should have approved this action) *///from ww w . jav a2 s . c o m public static void addGroupFromInvite(final Context c, final String groupName, final String sharedFeedName, final long inviterContactId, final String dynUpdateUri) { ContentValues values = new ContentValues(); values.put("groupName", groupName); values.put("sharedFeedName", sharedFeedName); values.put("inviterContactId", inviterContactId); values.put("inviterContactId", inviterContactId); Uri url = Uri.parse(DungBeetleContentProvider.CONTENT_URI + "/groups_by_invitation"); c.getContentResolver().insert(url, values); }
From source file:org.jsharkey.sky.webservice.WebserviceHelper.java
/** * Perform a webservice query to retrieve and store the forecast for the * given widget. This call blocks until request is finished and * {@link Forecasts#CONTENT_URI} has been updated. *//*w w w. j a v a2 s .com*/ public static void updateForecasts(Context context, Uri appWidgetUri, int days) throws ParseException { if (sUserAgent == null) { prepareUserAgent(context); } Uri appWidgetForecasts = Uri.withAppendedPath(appWidgetUri, AppWidgets.TWIG_FORECASTS); ContentResolver resolver = context.getContentResolver(); Cursor cursor = null; double lat = Double.NaN; double lon = Double.NaN; String countryCode = null; // Pull exact forecast location from database try { cursor = resolver.query(appWidgetUri, PROJECTION_APPWIDGET, null, null, null); if (cursor != null && cursor.moveToFirst()) { lat = cursor.getDouble(COL_LAT); lon = cursor.getDouble(COL_LON); countryCode = cursor.getString(COL_COUNTRY_CODE); } } finally { if (cursor != null) { cursor.close(); } } Log.d(TAG, "using country code=" + countryCode); // Query webservice for this location List<Forecast> forecasts = null; if (COUNTRY_US.equals(countryCode)) { forecasts = new NoaaSource().getForecasts(lat, lon, days); } else { forecasts = new MetarSource().getForecasts(lat, lon, days); } if (forecasts == null || forecasts.size() == 0) { throw new ParseException("No forecasts found from webservice query"); } // Purge existing forecasts covered by incoming data, and anything // before today long lastMidnight = ForecastUtils.getLastMidnight(); long earliest = Long.MAX_VALUE; for (Forecast forecast : forecasts) { earliest = Math.min(earliest, forecast.validStart); } resolver.delete(appWidgetForecasts, ForecastsColumns.VALID_START + " >= " + earliest + " OR " + ForecastsColumns.VALID_START + " <= " + lastMidnight, null); // Insert any new forecasts found ContentValues values = new ContentValues(); for (Forecast forecast : forecasts) { Log.d(TAG, "inserting forecast with validStart=" + forecast.validStart); values.clear(); values.put(ForecastsColumns.VALID_START, forecast.validStart); values.put(ForecastsColumns.TEMP_HIGH, forecast.tempHigh); values.put(ForecastsColumns.TEMP_LOW, forecast.tempLow); values.put(ForecastsColumns.CONDITIONS, forecast.conditions); values.put(ForecastsColumns.URL, forecast.url); if (forecast.alert) { values.put(ForecastsColumns.ALERT, ForecastsColumns.ALERT_TRUE); } resolver.insert(appWidgetForecasts, values); } // Mark widget cache as being updated values.clear(); values.put(AppWidgetsColumns.LAST_UPDATED, System.currentTimeMillis()); resolver.update(appWidgetUri, values, null, null); }