List of usage examples for android.content ContentValues put
public void put(String key, byte[] value)
From source file:edu.stanford.mobisocial.dungbeetle.feed.objects.PresenceObj.java
public void handleDirectMessage(Context context, Contact from, JSONObject obj) { int presence = obj.optInt(PRESENCE); String id = Long.toString(from.id); long time = obj.optLong(DbObject.TIMESTAMP); ContentValues values = new ContentValues(); values.put(Contact.PRESENCE, presence); values.put(Contact.LAST_PRESENCE_TIME, time); context.getContentResolver().update(Uri.parse(DungBeetleContentProvider.CONTENT_URI + "/contacts"), values, "_id=?", new String[] { id }); }
From source file:net.benmoran.affectsampler.TestDataBuilder.java
public void addSample(double emotion, double intensity, String comment, Date date) throws JSONException { ContentValues values = new ContentValues(); values.put(AffectSamples.EMOTION, emotion); values.put(AffectSamples.INTENSITY, intensity); values.put(AffectSamples.COMMENT, comment); values.put(AffectSamples.SCHEDULED_DATE, date.getTime()); values.put(AffectSamples.CREATED_DATE, date.getTime()); mContentResolver.insert(AffectSamples.CONTENT_URI, values); mJSONArray.put(new JSONObject().put(AffectSamples.EMOTION, emotion).put(AffectSamples.INTENSITY, intensity) .put(AffectSamples.COMMENT, comment).put(AffectSamples.SCHEDULED_DATE, date.getTime()) .put(AffectSamples.CREATED_DATE, date.getTime())); }
From source file:com.manning.androidhacks.hack043.service.NoBatchService.java
@Override protected void onHandleIntent(Intent intent) { ContentResolver contentResolver = getContentResolver(); contentResolver.delete(NoBatchNumbersContentProvider.CONTENT_URI, null, null); for (int i = 1; i <= 100; i++) { ContentValues cv = new ContentValues(); cv.put(NoBatchNumbersContentProvider.COLUMN_TEXT, "" + i); contentResolver.insert(NoBatchNumbersContentProvider.CONTENT_URI, cv); }//from w ww . j av a 2s .c o m }
From source file:com.deliciousdroid.platform.ContactManager.java
/** * Add a list of status messages to the contacts provider. * // ww w .j a v a2 s . c o m * @param context the context to use * @param accountName the username of the logged in user * @param statuses the list of statuses to store */ public static void insertStatuses(Context context, String username, List<User.Status> list) { final ContentValues values = new ContentValues(); final ContentResolver resolver = context.getContentResolver(); final ArrayList<String> processedUsers = new ArrayList<String>(); final BatchOperation batchOperation = new BatchOperation(context, resolver); for (final User.Status status : list) { // Look up the user's sample SyncAdapter data row final String userName = status.getUserName(); if (!processedUsers.contains(userName)) { final long profileId = lookupProfile(resolver, userName); // Insert the activity into the stream if (profileId > 0) { values.put(StatusUpdates.DATA_ID, profileId); values.put(StatusUpdates.STATUS, status.getStatus()); values.put(StatusUpdates.PROTOCOL, Im.PROTOCOL_CUSTOM); values.put(StatusUpdates.CUSTOM_PROTOCOL, CUSTOM_IM_PROTOCOL); values.put(StatusUpdates.IM_ACCOUNT, username); values.put(StatusUpdates.IM_HANDLE, status.getUserName()); values.put(StatusUpdates.STATUS_TIMESTAMP, status.getTimeStamp().getTime()); values.put(StatusUpdates.STATUS_RES_PACKAGE, context.getPackageName()); values.put(StatusUpdates.STATUS_ICON, R.drawable.ic_main); values.put(StatusUpdates.STATUS_LABEL, R.string.label); batchOperation.add(ContactOperations.newInsertCpo(StatusUpdates.CONTENT_URI, true) .withValues(values).build()); // A sync adapter should batch operations on multiple contacts, // because it will make a dramatic performance difference. if (batchOperation.size() >= 50) { batchOperation.execute(); } } processedUsers.add(userName); } } batchOperation.execute(); }
From source file:com.manning.androidhacks.hack042.AddPoiActivity.java
public void onAddClick(View v) { String title = mTitleEditText.getText().toString(); String latitude = mLatitudeEditText.getText().toString(); String longitude = mLongitudeEditText.getText().toString(); DatabaseHelper dbHelper = new DatabaseHelper(this); SQLiteDatabase db = dbHelper.getWritableDatabase(); ContentValues cv = new ContentValues(); cv.put("title", title); cv.put("latitude", latitude); cv.put("longitude", longitude); db.insert("pois", null, cv); finish();//from w ww. j a v a 2 s. c o m }
From source file:com.lambdasoup.blockvote.base.comms.BlockvoteFirebaseMessagingService.java
private ContentValues fromJson(JSONObject jsonObject, String id, String timestamp) throws JSONException { ContentValues cv = new ContentValues(); cv.put(Stats.ID, id); cv.put(Stats.D30, jsonObject.getDouble("d30")); cv.put(Stats.D7, jsonObject.getDouble("d7")); cv.put(Stats.D1, jsonObject.getDouble("d1")); cv.put(Stats.TIME, timestamp);//from ww w . j ava2 s .c o m return cv; }
From source file:DictionaryDatabase.java
public long addRecord(String word, String definition) { SQLiteDatabase db = getWritableDatabase(); ContentValues values = new ContentValues(); values.put(FIELD_WORD, word); values.put(FIELD_DEFINITION, definition); return db.insert(TABLE_DICTIONARY, null, values); }
From source file:DictionaryDatabase.java
public int updateRecord(long id, String word, String definition) { SQLiteDatabase db = getWritableDatabase(); ContentValues values = new ContentValues(); values.put("_id", id); values.put(FIELD_WORD, word);/* w ww .j a v a2 s .co m*/ values.put(FIELD_DEFINITION, definition); return db.update(TABLE_DICTIONARY, values, "_id = ?", new String[] { String.valueOf(id) }); }
From source file:Main.java
public static void shiftTableUriIds(HashMap<String, ArrayList<ContentValues>> operationMap, String tableName, String idColumnName, String authority, String path, long topTableId) { ArrayList<ContentValues> restoreOperations = operationMap.get(tableName); if (null == restoreOperations) { return;/*from w ww .jav a2 s .c o m*/ } for (ContentValues restoreCv : restoreOperations) { if (restoreCv.containsKey(idColumnName) && null != restoreCv.getAsString(idColumnName)) { Uri uri = Uri.parse(restoreCv.getAsString(idColumnName)); if ("content".equalsIgnoreCase(uri.getScheme()) && authority.equals(uri.getAuthority()) && uri.getPath().substring(0, uri.getPath().lastIndexOf('/')).equals(path)) { Uri.Builder newUri = uri.buildUpon() .path(uri.getPath().substring(0, uri.getPath().lastIndexOf('/'))) .appendPath(String.valueOf( Long.parseLong(uri.getPath().substring(uri.getPath().lastIndexOf('/') + 1)) + topTableId)); // Log.v("URI", uri.getPath().substring(uri.getPath().lastIndexOf('/')+1)); // Log.v("URI", String.valueOf(Long.parseLong(uri.getPath().substring(uri.getPath().lastIndexOf('/')+1)) + topTableId)); restoreCv.put(idColumnName, newUri.build().toString()); } } } }
From source file:edu.stanford.mobisocial.dungbeetle.feed.objects.SharedSecretObj.java
public void handleDirectMessage(Context context, Contact from, JSONObject obj) { String raw_b64;/*from ww w .ja v a 2 s. c om*/ try { raw_b64 = obj.getString(RAW); } catch (JSONException e) { e.printStackTrace(); return; } byte[] ss = FastBase64.decode(raw_b64); if (from.secret != null && new BigInteger(from.secret).compareTo(new BigInteger(ss)) > 0) { //ignore the new key according to a time independent metric... return; } ContentValues values = new ContentValues(); values.put(Contact.SHARED_SECRET, ss); context.getContentResolver().update(Uri.parse(DungBeetleContentProvider.CONTENT_URI + "/contacts"), values, "_id=?", new String[] { String.valueOf(from.id) }); }