List of usage examples for android.content ContentValues put
public void put(String key, byte[] value)
From source file:com.csipsimple.backup.Columns.java
private static void j2cvInt(JSONObject j, ContentValues cv, String key) { try {//from w ww . j a v a 2s .c o m int v = j.getInt(key); cv.put(key, v); } catch (JSONException e) { } }
From source file:gxu.software_engineering.market.android.util.Processor.java
public static ContentValues toItem(JSONObject json) throws JSONException { ContentValues values = new ContentValues(); JSONObject category = json.getJSONObject(C.CATEGORY); JSONObject seller = json.getJSONObject(C.SELLER); values.put(C._ID, json.getLong(C.ID)); values.put(C.item.ADDED_TIME, json.getLong(C.item.ADDED_TIME)); values.put(C.item.CATEGORY, category.getString(C.category.NAME)); values.put(C.item.CLICK_TIMES, json.getLong(C.item.CLICK_TIMES)); values.put(C.item.CLOSED, json.getString(C.item.CLOSED)); values.put(C.item.DEAL, json.getString(C.item.DEAL)); values.put(C.item.DESCRIPTION, json.getString(C.item.DESCRIPTION)); values.put(C.item.EXTRA, json.getString(C.item.EXTRA)); values.put(C.item.LAST_MODIFIED_TIME, json.getLong(C.item.LAST_MODIFIED_TIME)); values.put(C.item.NAME, json.getString(C.item.NAME)); values.put(C.item.PRICE, json.getDouble(C.item.PRICE)); values.put(C.item.SELLER, seller.getString(C.user.NICK)); values.put(C.item.SELLER_ID, seller.getLong(C.ID)); values.put(C.item.CID, category.getLong(C.ID)); return values; }
From source file:edu.mit.mobile.android.livingpostcards.data.Card.java
public static boolean setCollaborative(ContentResolver cr, Uri card, boolean collaborative) { final ContentValues cv = new ContentValues(); cv.put(Card.COL_PRIVACY, collaborative ? Card.PRIVACY_PUBLIC : Card.PRIVACY_PROTECTED); final int count = cr.update(card, cv, null, null); return count >= 1; }
From source file:com.csipsimple.backup.Columns.java
private static void j2cvLong(JSONObject j, ContentValues cv, String key) { try {//from w ww . ja v a 2 s. c o m long v = j.getLong(key); cv.put(key, v); } catch (JSONException e) { } }
From source file:edu.mit.mobile.android.livingpostcards.data.Card.java
/** * Creates a new card with a random UUID. Cards are marked DRAFT by default. * * @param cr/*www. jav a2 s. co m*/ * @param title * @return */ public static Uri createNewCard(Context context, Account account, String title) { final ContentValues cv = new ContentValues(); cv.put(Card.COL_TITLE, title); return createNewCard(context, account, cv); }
From source file:edu.mit.mobile.android.locast.data.interfaces.LocatableUtils.java
/** * Adds the appropriate {@link Authorable#COL_LATITUDE}, {@link Authorable#COL_LONGITUDE} * columns to the given {@link ContentValues} for the given location. * * @param cv/* w w w . j a v a 2s . c om*/ * @param location * @return the same {@link ContentValues} that was passed in. */ public static ContentValues toContentValues(ContentValues cv, Location location) { cv.put(Locatable.COL_LATITUDE, location.getLatitude()); cv.put(Locatable.COL_LONGITUDE, location.getLongitude()); return cv; }
From source file:android.provider.Checkin.java
/** * Helper function to log an event to the database. * * @param resolver from {@link android.content.Context#getContentResolver} * @param tag identifying the type of event being recorded * @param value associated with event, if any * @return URI of the event that was added *///from w w w .j av a 2 s. c o m static public Uri logEvent(ContentResolver resolver, Events.Tag tag, String value) { try { // Don't specify the date column; the content provider will add that. ContentValues values = new ContentValues(); values.put(Events.TAG, tag.toString()); if (value != null) values.put(Events.VALUE, value); return resolver.insert(Events.CONTENT_URI, values); } catch (SQLException e) { Log.e(TAG, "Can't log event: " + tag, e); // Database errors are not fatal. return null; } }
From source file:at.bitfire.ical4android.AndroidTaskList.java
@SuppressLint("InlinedApi") public static Uri create(Account account, TaskProvider provider, ContentValues info) throws CalendarStorageException { info.put(TaskContract.ACCOUNT_NAME, account.name); info.put(TaskContract.ACCOUNT_TYPE, account.type); info.put(TaskLists.ACCESS_LEVEL, 0); Log.i(TAG, "Creating local task list: " + info.toString()); try {//from www .ja v a 2 s . co m return provider.client.insert(syncAdapterURI(provider.taskListsUri(), account), info); } catch (RemoteException e) { throw new CalendarStorageException("Couldn't create local task list", e); } }
From source file:android.provider.Checkin.java
/** * Helper function to update statistics in the database. * Note that multiple updates to the same tag will be combined. * * @param tag identifying what is being observed * @param count of occurrences/*from www . j av a 2 s . c om*/ * @param sum of some value over these occurrences * @return URI of the statistic that was returned */ static public Uri updateStats(ContentResolver resolver, Stats.Tag tag, int count, double sum) { try { ContentValues values = new ContentValues(); values.put(Stats.TAG, tag.toString()); if (count != 0) values.put(Stats.COUNT, count); if (sum != 0.0) values.put(Stats.SUM, sum); return resolver.insert(Stats.CONTENT_URI, values); } catch (SQLException e) { Log.e(TAG, "Can't update stat: " + tag, e); // Database errors are not fatal. return null; } }
From source file:com.csipsimple.backup.Columns.java
private static void j2cvString(JSONObject j, ContentValues cv, String key) { try {/*from w w w . j av a2 s .c o m*/ String v = j.getString(key); cv.put(key, v); } catch (JSONException e) { } }