Code example for ContentValues

Methods: clearput, withValues

0
	 
	public ContactOperations updateAvatar(Uri uri, String existingAvatarUrl, String avatarUrl) {
		if (avatarUrl != null && !TextUtils.equals(existingAvatarUrl, avatarUrl)) {
			byte[] avatarBuffer = NetworkUtilities.downloadAvatar(avatarUrl);
			if (avatarBuffer != null) {
				mValues.clear();
				mValues.put(Photo.DATA1, avatarUrl);
				mValues.put(Photo.PHOTO, avatarBuffer);
				mValues.put(Photo.MIMETYPE, Photo.CONTENT_ITEM_TYPE);
				addUpdateOp(uri);
			} 
		} 
		return this;
	} 
	 
	public ContactOperations updateProfileAction(Integer userId, Uri uri) {
		mValues.clear();
		mValues.put(SyncAdapterColumns.DATA_PID, userId);
		addUpdateOp(uri);
		return this;
	} 
	 
	private void addInsertOp() { 
		if (!mIsNewContact) {
			mValues.put(Phone.RAW_CONTACT_ID, mRawContactId);
		} 
		ContentProviderOperation.Builder builder = newInsertCpo(
				Data.CONTENT_URI, mIsSyncOperation, mIsYieldAllowed);
		builder.withValues(mValues);
		if (mIsNewContact) {
			builder.withValueBackReference(Data.RAW_CONTACT_ID, mBackReference);
		} 
		mIsYieldAllowed = false;
		mBatchOperation.add(builder.build());
	} 
	 
	private void addUpdateOp(Uri uri) {
		ContentProviderOperation.Builder builder = newUpdateCpo(uri,
				mIsSyncOperation, mIsYieldAllowed).withValues(mValues);
		mIsYieldAllowed = false;
		mBatchOperation.add(builder.build());
	} 
	 
Contextual code suggestions in your IDE  Get Codota for Java