List of usage examples for android.content ContentValues ContentValues
public ContentValues()
From source file:cn.newgxu.android.notty.util.Processor.java
public static ContentValues json2User(JSONObject u) { ContentValues v = new ContentValues(); try {/*w ww . j ava 2 s . co m*/ v.put(C._ID, u.getLong(C.ID)); v.put(C.user.ABOUT, u.getString(C.user.ABOUT)); v.put(C.user.AUTHED_NAME, u.getString(C.user.AUTHED_NAME)); v.put(C.user.CONTACT, u.getString(C.user.CONTACT)); v.put(C.user.JOIN_TIME, u.getLong(C.user.JOIN_TIME)); v.put(C.user.ORG, u.getString(C.user.ORG)); } catch (JSONException e) { throw new RuntimeException("resolve json wrong -> " + u); } return v; }
From source file:cn.sharesdk.analysis.db.MessageUtils.java
/** * ??/* w w w .ja v a 2s. c om*/ * @param c * @param msg */ public static synchronized long insertMsg(Context c, String type, String data) { if (TextUtils.isEmpty(data)) { return -1; } DBProvider provider = DBProvider.getDBProvider(c); ContentValues value = new ContentValues(); value.put(DBHelp.COLUMN_EVENT_TYPE, type); value.put(DBHelp.COLUMN_EVENT_DATA, data); long id = provider.insert(DBHelp.TABLE_STATISTICS, value); //Ln.e("threadID == %s, insert ID == %s ", time , id); return 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: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);//from w ww . java 2s . co m values.put(FIELD_DEFINITION, definition); return db.update(TABLE_DICTIONARY, values, "_id = ?", new String[] { String.valueOf(id) }); }
From source file:co.rewen.statex.AsyncLocalStorageUtil.java
/** * Sets the value for the key given, returns true if successful, false otherwise. */// w ww . j av a 2 s. c om /* package */ static boolean setItemImpl(SQLiteDatabase db, String key, String value) { ContentValues contentValues = new ContentValues(); contentValues.put(KEY_COLUMN, key); contentValues.put(VALUE_COLUMN, value); long inserted = db.insertWithOnConflict(TABLE_STATE, null, contentValues, SQLiteDatabase.CONFLICT_REPLACE); return (-1 != inserted); }
From source file:net.nordist.lloydproof.CorrectionStorage.java
public int save(String currentText) { ContentValues values = new ContentValues(); values.put("current_text", currentText); openWriteDB();/*from ww w . j a v a2 s.c o m*/ int savedId = (int) writeDB.insert(TABLE_NAME, null, values); if (savedId > 0) { Log.d(TAG, "saved correction as id=" + savedId); } else { Log.e(TAG, "error saving correction"); } return savedId; }
From source file:com.granita.contacticloudsync.resource.LocalCalendar.java
@TargetApi(15) public static Uri create(Account account, ContentResolver resolver, ServerInfo.ResourceInfo info) throws CalendarStorageException { @Cleanup("release") ContentProviderClient provider = resolver.acquireContentProviderClient(CalendarContract.AUTHORITY); if (provider == null) throw new CalendarStorageException( "Couldn't acquire ContentProviderClient for " + CalendarContract.AUTHORITY); ContentValues values = new ContentValues(); values.put(Calendars.NAME, info.getUrl()); values.put(Calendars.CALENDAR_DISPLAY_NAME, info.getTitle()); values.put(Calendars.CALENDAR_COLOR, info.color != null ? info.color : defaultColor); if (info.isReadOnly()) values.put(Calendars.CALENDAR_ACCESS_LEVEL, Calendars.CAL_ACCESS_READ); else {//from w w w . jav a 2 s.co m values.put(Calendars.CALENDAR_ACCESS_LEVEL, Calendars.CAL_ACCESS_OWNER); values.put(Calendars.CAN_MODIFY_TIME_ZONE, 1); values.put(Calendars.CAN_ORGANIZER_RESPOND, 1); } values.put(Calendars.OWNER_ACCOUNT, account.name); values.put(Calendars.SYNC_EVENTS, 1); values.put(Calendars.VISIBLE, 1); if (!TextUtils.isEmpty(info.timezone)) { VTimeZone timeZone = DateUtils.parseVTimeZone(info.timezone); if (timeZone != null && timeZone.getTimeZoneId() != null) values.put(Calendars.CALENDAR_TIME_ZONE, DateUtils.findAndroidTimezoneID(timeZone.getTimeZoneId().getValue())); } values.put(Calendars.ALLOWED_REMINDERS, Reminders.METHOD_ALERT); if (Build.VERSION.SDK_INT >= 15) { values.put(Calendars.ALLOWED_AVAILABILITY, StringUtils.join(new int[] { Reminders.AVAILABILITY_TENTATIVE, Reminders.AVAILABILITY_FREE, Reminders.AVAILABILITY_BUSY }, ",")); values.put(Calendars.ALLOWED_ATTENDEE_TYPES, StringUtils.join(new int[] { CalendarContract.Attendees.TYPE_OPTIONAL, CalendarContract.Attendees.TYPE_REQUIRED, CalendarContract.Attendees.TYPE_RESOURCE }, ", ")); } return create(account, provider, values); }
From source file:com.nbos.phonebook.sync.platform.ContactManager.java
/** * Add a list of status messages to the contacts provider. * //from ww w .jav a 2 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 BatchOperation batchOperation = new BatchOperation(context); for (final User.Status status : list) { // Look up the user's sample SyncAdapter data row final long userId = status.getUserId(); final long profileId = lookupProfile(resolver, userId); // 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.getUserId()); values.put(StatusUpdates.STATUS_RES_PACKAGE, context.getPackageName()); values.put(StatusUpdates.STATUS_ICON, R.drawable.icon); 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(); } } } batchOperation.execute(); }
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:com.todoroo.astrid.data.RemoteModel.java
public void setUuid(String uuid) { if (setValues == null) { setValues = new ContentValues(); }//from w w w . ja v a 2 s. c om if (NO_UUID.equals(uuid)) { clearValue(UUID_PROPERTY); } else { setValues.put(UUID_PROPERTY_NAME, uuid); } }