Android ContentProviderOperation.Builder - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android ContentProviderOperation.Builder class.

This code example shows how to use the following methods:clear, put, withValues
        return this;
    } 
 
    public ContactOperations updateDirtyFlag(boolean isDirty, Uri uri) {
        int isDirtyValue = isDirty ? 1 : 0;
        mValues.clear();
        mValues.put(RawContacts.DIRTY, isDirtyValue);
        addUpdateOp(uri);
        return this;
    } 
 
    /** 
     * Updates contact's phone 
     * 
     * @param existingNumber phone number stored in contacts provider 
     * @param phone new phone number for the contact 
     * @param uri Uri for the existing raw contact to be updated 
     * @return instance of ContactOperations 
     */ 
    public ContactOperations updatePhone(String existingNumber, String phone, Uri uri) {

7
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:clear, put, size, withValues
		mIsNewContact = false;
		mRawContactId = rawContactId;
	} 
	 
	public ContactOperations addName(String firstName, String lastName) {
		mValues.clear();
		 
		if (!TextUtils.isEmpty(firstName)) {
			mValues.put(StructuredName.GIVEN_NAME, firstName);
			mValues.put(StructuredName.MIMETYPE,
					StructuredName.CONTENT_ITEM_TYPE);
		} 
		if (!TextUtils.isEmpty(lastName)) {
			mValues.put(StructuredName.FAMILY_NAME, lastName);
			mValues.put(StructuredName.MIMETYPE,
					StructuredName.CONTENT_ITEM_TYPE);
		} 
		if (mValues.size() > 0) {
			addInsertOp(); 
		} 

7
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:clear, put, size, withValues
     * @param name Name of contact 
     * @param nameType type of name: family name, given name, etc. 
     * @return instance of ContactOperations 
     */ 
    public ContactOperations addName(String firstName) {
        mValues.clear();
        if (!TextUtils.isEmpty(firstName)) {
            mValues.put(StructuredName.GIVEN_NAME, firstName);
            mValues.put(StructuredName.MIMETYPE,
                StructuredName.CONTENT_ITEM_TYPE);
        } 
        if (mValues.size() > 0) {
            addInsertOp(); 
        } 
        return this;
    } 
 
    /** 
     * Adds an email 
     *  

7
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:clear, put, size, withValues
     * @param name Name of contact 
     * @param nameType type of name: family name, given name, etc. 
     * @return instance of ContactOperations 
     */ 
    public ContactOperations addName(String firstName) {
        mValues.clear();
        if (!TextUtils.isEmpty(firstName)) {
            mValues.put(StructuredName.GIVEN_NAME, firstName);
            mValues.put(StructuredName.MIMETYPE,
                StructuredName.CONTENT_ITEM_TYPE);
        } 
        if (mValues.size() > 0) {
            addInsertOp(); 
        } 
        return this;
    } 
 
    /** 
     * Adds an email 
     *  

6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:clear, put, size, withValues
    public ContactOperations updateName(Uri uri, String existingFirstName,
        String existingLastName, String firstName, String lastName) {
        Log.i("ContactOperations", "u;ef=" + existingFirstName + ";el="
            + existingLastName + ";f=" + firstName + ";l=" + lastName);
 
        mValues.clear();
        if (!TextUtils.equals(existingFirstName,firstName)) {
            mValues.put(StructuredName.GIVEN_NAME, firstName);
            mValues.put(StructuredName.MIMETYPE,
                StructuredName.CONTENT_ITEM_TYPE);
        } 
        if (!TextUtils.equals(existingLastName, lastName)) {
            mValues.put(StructuredName.FAMILY_NAME, lastName);
            mValues.put(StructuredName.MIMETYPE,
                StructuredName.CONTENT_ITEM_TYPE);
        } 
        if (mValues.size() > 0) {
            addUpdateOp(uri);
        } 
        return this;

6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:clear, put, size, withValues
	 * @param lastName Last name of contact 
	 * @return instance of SyncContactOperations 
	 */ 
	public final SyncContactOperations addName(final String firstName, final String lastName) {
		//Log.d(TAG, "adding Name: " + firstName + ", " + lastName); 
		mValues.clear();
		if (!TextUtils.isEmpty(firstName) && !firstName.equals("null")) {
			mValues.put(StructuredName.GIVEN_NAME, firstName);
			mValues.put(StructuredName.MIMETYPE,
					StructuredName.CONTENT_ITEM_TYPE);
		} 
		if (!TextUtils.isEmpty(lastName) && !lastName.equals("null")) {
			mValues.put(StructuredName.FAMILY_NAME, lastName);
			mValues.put(StructuredName.MIMETYPE,
					StructuredName.CONTENT_ITEM_TYPE);
		} 
		if (mValues.size() > 0) {
			addInsertOp(); 
		} 
		return this;

6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:remove, withValues
    private void updatePhoto(ContentValues values, Uri rawContactDataUri,
            boolean allowInsert) {
        ArrayList<ContentProviderOperation> operations =
            new ArrayList<ContentProviderOperation>();
 
        values.remove(Photo.MIMETYPE);
 
        // check that a photo exists 
        operations.add(ContentProviderOperation.newAssertQuery(rawContactDataUri)
                .withSelection(Photo.MIMETYPE + "=?", new String[] {
                    Photo.CONTENT_ITEM_TYPE
                }).withExpectedCount(1).build());
 
        // update that photo 
        operations.add(ContentProviderOperation.newUpdate(rawContactDataUri)
                .withSelection(Photo.MIMETYPE + "=?", new String[] {Photo.CONTENT_ITEM_TYPE})
                .withValues(values).build());
 
        try { 
            mContentResolver.applyBatch(ContactsContract.AUTHORITY, operations);

6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getAsLong, withValues
 
    private ContentProviderOperation insertOperation() {
        Uri uri = ModelManager.getContentUri(getModelInterface());
        return ContentProviderOperation 
                .newInsert(uri)
                .withValues(mValues)
                .build();
    } 
 
    private ContentProviderOperation updateOperation() {
        Uri uri = getUri();
        return ContentProviderOperation 
                .newUpdate(uri)
                .withExpectedCount(1)
                .withValues(mValues)
                .build();
    } 
 
    ////////// CalicoModel implementation ////////// 
 

5
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:build
     * appending it to the given list, which only happens if builder is valid. 
     */ 
    private void possibleAdd(ArrayList<ContentProviderOperation> diff,
            ContentProviderOperation.Builder builder) {
        if (builder != null) {
            diff.add(builder.build());
        } 
    } 
 
    /** 
     * Build a list of {@link ContentProviderOperation} that will assert any 
     * "before" state hasn't changed. This is maintained separately so that all 
     * asserts can take place before any updates occur. 
     */ 
    public void buildAssert(ArrayList<ContentProviderOperation> buildInto) {
        final boolean isContactInsert = mValues.isInsert();
        if (!isContactInsert) {
            // Assert version is consistent while persisting changes 
            final Long beforeId = mValues.getId();
            final Long beforeVersion = mValues.getAsLong(RawContacts.VERSION);
5
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:build
     * appending it to the given list, which only happens if builder is valid. 
     */ 
    private void possibleAdd(ArrayList<ContentProviderOperation> diff,
            ContentProviderOperation.Builder builder) {
        if (builder != null) {
            diff.add(builder.build());
        } 
    } 
 
    /** 
     * Build a list of {@link ContentProviderOperation} that will assert any 
     * "before" state hasn't changed. This is maintained separately so that all 
     * asserts can take place before any updates occur. 
     */ 
    public void buildAssert(ArrayList<ContentProviderOperation> buildInto) {
        final boolean isContactInsert = mValues.isInsert();
        if (!isContactInsert) {
            // Assert version is consistent while persisting changes 
            final Long beforeId = mValues.getId();
            final Long beforeVersion = mValues.getAsLong(RawContacts.VERSION);
4
CodeRank
Experience pair programming with AI  Get Codota for Java

Related Android ContentProviderOperation.Builder Questions & Answers:

See Code Examples for Android ContentProviderOperation.Builder Methods: