Example usage for android.content ContentProviderOperation newUpdate

List of usage examples for android.content ContentProviderOperation newUpdate

Introduction

In this page you can find the example usage for android.content ContentProviderOperation newUpdate.

Prototype

public static Builder newUpdate(Uri uri) 

Source Link

Document

Create a Builder suitable for building an update ContentProviderOperation .

Usage

From source file:org.xwalk.runtime.extension.api.contacts.ContactSaver.java

private Builder newUpdateBuilder(String mimeType) {
    Builder builder = ContentProviderOperation.newUpdate(Data.CONTENT_URI);
    builder.withSelection(Data.CONTACT_ID + "=? AND " + Data.MIMETYPE + "=?", new String[] { mId, mimeType });
    return builder;
}

From source file:fr.mixit.android.io.JsonHandlerApplyStarredSessions.java

@Override
public boolean parseItem(JSONObject item, ContentResolver resolver) throws JSONException {
    final String id = item.getString(TAG_ID);
    mItemIds.add(id);//from w  w w .j  a v  a  2  s  .c o  m

    final Uri itemUri = MixItContract.Sessions.buildSessionUri(id);

    ContentProviderOperation.Builder builder = null;

    boolean build = false;

    if (ProviderParsingUtils.isRowExisting(itemUri, MixItContract.Sessions.PROJ_DETAIL.PROJECTION, resolver)) {
        builder = ContentProviderOperation.newUpdate(itemUri);
        builder.withValue(MixItContract.Sessions.IS_FAVORITE, 1);
        build = true;
    } else {
        if (DEBUG_MODE) {
            Log.e(TAG,
                    "Impossible to set starred session with id " + id + " because this session was not found");
        }
    }

    if (build && builder != null) {
        ProviderParsingUtils.addOpeAndApplyBatch(mAuthority, resolver, mBatch, false, builder.build());
    }

    return true;
}

From source file:net.niyonkuru.koodroid.html.SubscribersHandler.java

@Override
public ArrayList<ContentProviderOperation> parse(Document doc, ContentResolver resolver)
        throws HandlerException {
    final ArrayList<ContentProviderOperation> batch = new ArrayList<ContentProviderOperation>();

    Element subscriberLi = doc.select("div#banSelector li:has(div)").first();
    while (subscriberLi != null) {
        String text = subscriberLi.text();

        /* this assumes the name and phone number are separated by a space */
        int separator = text.lastIndexOf(' ') + 1;

        String subscriberId = text.substring(separator).replaceAll("\\D", "");
        if (subscriberId.length() != 10)
            throw new HandlerException(getString(R.string.parser_error_unexpected_input));

        final ContentProviderOperation.Builder builder;

        final Uri subscriberUri = Subscribers.buildSubscriberUri(subscriberId);
        if (subscriberExists(subscriberUri, resolver)) {
            builder = ContentProviderOperation.newUpdate(subscriberUri);
            builder.withValue(Subscribers.UPDATED, System.currentTimeMillis());
        } else {// w  w w  .j a  v  a  2  s  .c o  m
            builder = ContentProviderOperation.newInsert(Subscribers.CONTENT_URI);
        }
        builder.withValue(Subscribers.SUBSCRIBER_ID, subscriberId);

        String fullName = "";
        String[] names = text.substring(0, separator).split("\\s");
        for (String name : names) {
            fullName += ParserUtils.capitalize(name) + " ";
        }
        builder.withValue(Subscribers.SUBSCRIBER_FULL_NAME, fullName.trim());

        if (subscriberLi.hasAttr("onClick")) {
            String switchUrl = subscriberLi.attr("onClick");

            /* extract only the url */
            switchUrl = switchUrl.substring(switchUrl.indexOf('/'), switchUrl.lastIndexOf('\''));
            builder.withValue(Subscribers.SUBSCRIBER_SWITCHER, switchUrl);
        } else { /* this is the default subscriber as it doesn't have a switcher url */
            ContentValues cv = new ContentValues(1);
            cv.put(Settings.SUBSCRIBER, subscriberId);

            resolver.insert(Settings.CONTENT_URI, cv);
        }
        builder.withValue(Subscribers.SUBSCRIBER_EMAIL, mParent);

        batch.add(builder.build());

        subscriberLi = subscriberLi.nextElementSibling();
    }
    if (batch.size() == 0)
        throw new HandlerException(getString(R.string.parser_error_unexpected_input));

    JSONObject metadata = new JSONObject();
    try {
        metadata.put("subscribers", batch.size());
        metadata.put("language", getString(R.string.locale));
    } catch (JSONException ignored) {
    }
    Crittercism.setMetadata(metadata);
    Crittercism.setUsername(mParent);

    return batch;
}

From source file:net.peterkuterna.android.apps.devoxxsched.io.RemoteRoomsHandler.java

@Override
public ArrayList<ContentProviderOperation> parse(ArrayList<JSONArray> entries, ContentResolver resolver)
        throws JSONException {
    final ArrayList<ContentProviderOperation> batch = Lists.newArrayList();
    final HashSet<String> roomIds = new HashSet<String>();

    int nrEntries = 0;
    for (JSONArray rooms : entries) {
        Log.d(TAG, "Retrieved " + rooms.length() + " room entries.");
        nrEntries += rooms.length();/*w w w . j a  v  a  2 s. c om*/

        for (int i = 0; i < rooms.length(); i++) {
            JSONObject room = rooms.getJSONObject(i);
            String id = room.getString("id");

            final String roomId = sanitizeId(id);
            final Uri roomUri = Rooms.buildRoomUri(roomId);
            roomIds.add(roomId);

            ContentProviderOperation.Builder builder;
            if (isRowExisting(Rooms.buildRoomUri(roomId), RoomsQuery.PROJECTION, resolver)) {
                builder = ContentProviderOperation.newUpdate(roomUri);
            } else {
                builder = ContentProviderOperation.newInsert(Rooms.CONTENT_URI);
                builder.withValue(Rooms.ROOM_ID, roomId);
            }
            builder.withValue(Rooms.NAME, room.getString("name"));
            builder.withValue(Rooms.CAPACITY, room.getString("capacity"));
            batch.add(builder.build());
        }
    }

    if (isRemoteSync() && nrEntries > 0) {
        for (String lostId : getLostIds(roomIds, Rooms.CONTENT_URI, RoomsQuery.PROJECTION, RoomsQuery.ROOM_ID,
                resolver)) {
            final Uri lostRoomUri = Rooms.buildRoomUri(lostId);
            batch.add(ContentProviderOperation.newDelete(lostRoomUri).build());
        }
    }

    return batch;
}

From source file:fr.mixit.android.io.RemoteSpeakersHandler.java

@Override
public ArrayList<ContentProviderOperation> parse(ArrayList<JSONArray> entries, ContentResolver resolver)
        throws JSONException {
    final ArrayList<ContentProviderOperation> batch = Lists.newArrayList();
    final HashSet<String> speakerIds = new HashSet<String>();

    int nrEntries = 0;
    for (JSONArray speakers : entries) {
        Log.d(TAG, "Retrieved " + speakers.length() + " speaker entries.");
        nrEntries += speakers.length();//from   w  ww .  j  a v  a  2  s.com

        for (int i = 0; i < speakers.length(); i++) {
            JSONObject speaker = speakers.getJSONObject(i);
            String id = speaker.getString("id");

            //              final String speakerId = sanitizeId(id);
            final Uri speakerUri = MixItContract.Speakers.buildSpeakerUri(id);
            speakerIds.add(id);

            boolean speakerUpdated = false;
            boolean newSpeaker = false;
            boolean build = false;
            ContentProviderOperation.Builder builder;
            if (isRowExisting(speakerUri, SpeakersQuery.PROJECTION, resolver)) {
                builder = ContentProviderOperation.newUpdate(speakerUri);
                speakerUpdated = isSpeakerUpdated(speakerUri, speaker, resolver);
            } else {
                newSpeaker = true;
                builder = ContentProviderOperation.newInsert(MixItContract.Speakers.CONTENT_URI);
                builder.withValue(MixItContract.Speakers.SPEAKER_ID, id);
                build = true;
            }

            if (newSpeaker || speakerUpdated) {
                builder.withValue(MixItContract.Speakers.LAST_NAME, speaker.getString("lastName"));
                builder.withValue(MixItContract.Speakers.FIRST_NAME, speaker.getString("firstName"));
                builder.withValue(MixItContract.Speakers.BIO, speaker.getString("bio"));
                builder.withValue(MixItContract.Speakers.LINKEDIN, speaker.getString("linkedin"));
                builder.withValue(MixItContract.Speakers.TWITTER, speaker.getString("twitter"));
                builder.withValue(MixItContract.Speakers.BLOG, speaker.getString("blog"));
                builder.withValue(MixItContract.Speakers.COMPANY, speaker.getString("company"));
                builder.withValue(MixItContract.Speakers.IMAGE_URL, speaker.getString("urlImage"));
                build = true;
            }
            if (build)
                batch.add(builder.build());
        }
    }

    // delete sessions with speakers deleted
    if (isRemoteSync() && nrEntries > 0) {
        for (String lostId : getLostIds(speakerIds, MixItContract.Speakers.CONTENT_URI,
                SpeakersQuery.PROJECTION, SpeakersQuery.SPEAKER_ID, resolver)) {
            Uri deleteUri = MixItContract.Speakers.buildSessionsDirUri(lostId);
            batch.add(ContentProviderOperation.newDelete(deleteUri).build());
            deleteUri = MixItContract.Speakers.buildSpeakerUri(lostId);
            batch.add(ContentProviderOperation.newDelete(deleteUri).build());
        }
    }

    return batch;
}

From source file:fr.mixit.android.io.JsonHandlerApplyInterests.java

@Override
public boolean parseItem(JSONObject item, ContentResolver resolver) throws JSONException {
    final String id = item.getString(TAG_ID);
    mItemIds.add(id);/* w  w  w.ja  v  a 2s  .c  o  m*/

    final Uri itemUri = MixItContract.Interests.buildInterestUri(id);

    boolean itemUpdated = false;
    boolean newItem = false;
    boolean build = false;
    ContentProviderOperation.Builder builder;

    if (ProviderParsingUtils.isRowExisting(itemUri, MixItContract.Interests.PROJ.PROJECTION, resolver)) {
        builder = ContentProviderOperation.newUpdate(itemUri);
        itemUpdated = isItemUpdated(itemUri, item, resolver);
    } else {
        newItem = true;
        builder = ContentProviderOperation.newInsert(MixItContract.Interests.CONTENT_URI);
        builder.withValue(MixItContract.Interests.INTEREST_ID, id);
        build = true;
    }

    if (newItem || itemUpdated) {
        builder.withValue(MixItContract.Interests.NAME, item.getString(TAG_NAME));
        build = true;
    }
    if (build) {
        ProviderParsingUtils.addOpeAndApplyBatch(mAuthority, resolver, mBatch, false, builder.build());
    }

    return true;
}

From source file:net.peterkuterna.android.apps.devoxxsched.io.RemoteSpeakersHandler.java

@Override
public ArrayList<ContentProviderOperation> parse(ArrayList<JSONArray> entries, ContentResolver resolver)
        throws JSONException {
    final ArrayList<ContentProviderOperation> batch = Lists.newArrayList();
    final HashSet<String> speakerIds = new HashSet<String>();

    int nrEntries = 0;
    for (JSONArray speakers : entries) {
        Log.d(TAG, "Retrieved " + speakers.length() + " speaker entries.");
        nrEntries += speakers.length();//  w ww  . ja v a 2s . c o  m

        for (int i = 0; i < speakers.length(); i++) {
            JSONObject speaker = speakers.getJSONObject(i);
            String id = speaker.getString("id");

            final String speakerId = sanitizeId(id);
            final Uri speakerUri = Speakers.buildSpeakerUri(speakerId);
            speakerIds.add(speakerId);

            boolean speakerUpdated = false;
            boolean newSpeaker = false;
            boolean build = false;
            ContentProviderOperation.Builder builder;
            if (isRowExisting(Speakers.buildSpeakerUri(speakerId), SpeakersQuery.PROJECTION, resolver)) {
                builder = ContentProviderOperation.newUpdate(speakerUri);
                speakerUpdated = isSpeakerUpdated(speakerUri, speaker, resolver);
            } else {
                newSpeaker = true;
                builder = ContentProviderOperation.newInsert(Speakers.CONTENT_URI);
                builder.withValue(Speakers.SPEAKER_ID, speakerId);
                build = true;
            }

            if (newSpeaker || speakerUpdated) {
                builder.withValue(Speakers.FIRST_NAME, speaker.getString("firstName"));
                builder.withValue(Speakers.LAST_NAME, speaker.getString("lastName"));
                builder.withValue(Speakers.BIO, speaker.getString("bio"));
                builder.withValue(Speakers.COMPANY, speaker.getString("company"));
                builder.withValue(Speakers.IMAGE_URL, speaker.getString("imageURI"));
                build = true;
            }
            if (build)
                batch.add(builder.build());
        }
    }

    if (isRemoteSync() && nrEntries > 0) {
        for (String lostId : getLostIds(speakerIds, Speakers.CONTENT_URI, SpeakersQuery.PROJECTION,
                SpeakersQuery.SPEAKER_ID, resolver)) {
            Uri deleteUri = Speakers.buildSessionsDirUri(lostId);
            batch.add(ContentProviderOperation.newDelete(deleteUri).build());
            deleteUri = Speakers.buildSpeakerUri(lostId);
            batch.add(ContentProviderOperation.newDelete(deleteUri).build());
        }
    }

    return batch;
}

From source file:fr.mixit.android.io.RemoteSessionsHandler.java

@Override
public ArrayList<ContentProviderOperation> parse(ArrayList<JSONArray> entries, ContentResolver resolver)
        throws JSONException {
    final ArrayList<ContentProviderOperation> batch = Lists.newArrayList();
    final HashSet<String> sessionIds = Sets.newHashSet();
    final HashMap<String, HashSet<String>> sessionSpeakerIds = Maps.newHashMap();
    final HashMap<String, HashSet<String>> sessionTagIds = Maps.newHashMap();

    int nrEntries = 0;
    for (JSONArray sessions : entries) {
        Log.d(TAG, "Retrieved " + sessions.length() + " session entries.");
        nrEntries += sessions.length();/*from ww w  .  j  a v a  2 s .  co  m*/

        for (int i = 0; i < sessions.length(); i++) {
            JSONObject session = sessions.getJSONObject(i);
            String sessionId = session.getString("id");

            //               final String sessionId = sanitizeId(sessionId);
            final Uri sessionUri = MixItContract.Sessions.buildSessionUri(sessionId);
            sessionIds.add(sessionId);
            //              int isStarred = isStarred(sessionUri, resolver);

            boolean sessionUpdated = false;
            boolean newSession = false;
            ContentProviderOperation.Builder builder;
            if (isRowExisting(sessionUri, SessionsQuery.PROJECTION, resolver)) {
                builder = ContentProviderOperation.newUpdate(sessionUri);
                sessionUpdated = isSessionUpdated(sessionUri, session, resolver);
            } else {
                newSession = true;
                builder = ContentProviderOperation.newInsert(MixItContract.Sessions.CONTENT_URI);
                builder.withValue(MixItContract.Sessions.SESSION_ID, sessionId);
            }

            if (newSession || sessionUpdated) {
                builder.withValue(MixItContract.Sessions.TITLE, session.getString("name"));
                if (session.has("room")) {
                    String room = session.getString("room");
                    if (room == null || room.length() == 0) {
                        room = "";
                    }
                    builder.withValue(MixItContract.Sessions.ROOM, room);
                }
                builder.withValue(MixItContract.Sessions.SUMMARY, session.getString("description"));

                if (session.has("track")) {
                    final String trackId = session.getString("track");
                    builder.withValue(MixItContract.Sessions.TRACK_ID, trackId);
                }

                if (session.has("slot")) {
                    final String trackId = session.getString("slot");
                    builder.withValue(MixItContract.Sessions.SLOT_ID, trackId);
                }

                batch.add(builder.build());
            }

            if (session.has("speakers")) {
                final Uri speakerSessionsUri = MixItContract.Sessions.buildSpeakersDirUri(sessionId);
                final JSONArray speakers = session.getJSONArray("speakers");
                final HashSet<String> speakerIds = Sets.newHashSet();

                if (!isLocalSync()) {
                    final boolean sessionSpeakersUpdated = isSessionSpeakersUpdated(speakerSessionsUri,
                            speakers, resolver);
                    if (sessionSpeakersUpdated) {
                        Log.d(TAG, "Speakers of session with sessionId " + sessionId + " was udpated.");

                        batch.add(ContentProviderOperation.newUpdate(sessionUri)
                                .withValue(MixItContract.Sessions.UPDATED, true).build());
                    }
                }

                for (int j = 0; j < speakers.length(); j++) {
                    /*                   JSONObject speaker = speakers.getJSONObject(j);
                                               
                                         final String speakerId = speaker.getString("speakerId");
                                         speakerIds.add(speakerId);*/

                    final String speakerId = speakers.getString(j);
                    speakerIds.add(speakerId);

                    batch.add(ContentProviderOperation.newInsert(speakerSessionsUri)
                            .withValue(MixItDatabase.SessionsSpeakers.SPEAKER_ID, speakerId)
                            .withValue(MixItDatabase.SessionsSpeakers.SESSION_ID, sessionId).build());
                }

                sessionSpeakerIds.put(sessionId, speakerIds);
            }

            if (session.has("tags")) {
                final Uri tagSessionsUri = MixItContract.Sessions.buildTagsDirUri(sessionId);
                final JSONArray tags = session.getJSONArray("tags");
                final HashSet<String> tagIds = Sets.newHashSet();

                if (!isLocalSync()) {
                    final boolean sessionTagsUpdated = isSessionTagsUpdated(tagSessionsUri, tags, resolver);
                    if (sessionTagsUpdated) {
                        Log.d(TAG, "Tags of session with sessionId " + sessionId + " was udpated.");
                        batch.add(ContentProviderOperation.newUpdate(sessionUri)
                                .withValue(MixItContract.Sessions.UPDATED, true).build());
                    }
                }

                for (int j = 0; j < tags.length(); j++) {
                    /*                   JSONObject tag = tags.getJSONObject(j);
                            
                                         final String tagId = tag.getString("tagId");
                                         tagIds.add(tagId);*/

                    final String tagId = tags.getString(j);
                    tagIds.add(tagId);

                    batch.add(ContentProviderOperation.newInsert(tagSessionsUri)
                            .withValue(MixItDatabase.SessionsTags.TAG_ID, tagId)
                            .withValue(MixItDatabase.SessionsTags.SESSION_ID, sessionId).build());
                }

                sessionTagIds.put(sessionId, tagIds);
            }
        }
    }

    if (isRemoteSync() && nrEntries > 0) {
        for (Map.Entry<String, HashSet<String>> entry : sessionSpeakerIds.entrySet()) {
            String sessionId = entry.getKey();
            HashSet<String> speakerIds = entry.getValue();
            final Uri speakerSessionsUri = MixItContract.Sessions.buildSpeakersDirUri(sessionId);
            HashSet<String> lostSpeakerIds = getLostIds(speakerIds, speakerSessionsUri,
                    SpeakersQuery.PROJECTION, SpeakersQuery.SPEAKER_ID, resolver);
            for (String lostSpeakerId : lostSpeakerIds) {
                final Uri deleteUri = MixItContract.Sessions.buildSessionSpeakerUri(sessionId, lostSpeakerId);
                batch.add(ContentProviderOperation.newDelete(deleteUri).build());
            }
        }

        HashSet<String> lostSessionIds = getLostIds(sessionIds, MixItContract.Sessions.CONTENT_URI,
                SessionsQuery.PROJECTION, SessionsQuery.SESSION_ID, resolver);
        for (String lostSessionId : lostSessionIds) {
            Uri deleteUri = MixItContract.Sessions.buildSpeakersDirUri(lostSessionId);
            batch.add(ContentProviderOperation.newDelete(deleteUri).build());
            deleteUri = MixItContract.Sessions.buildSessionUri(lostSessionId);
            batch.add(ContentProviderOperation.newDelete(deleteUri).build());
        }
    }

    return batch;
}

From source file:net.peterkuterna.android.apps.devoxxsched.io.RemoteScheduleHandler.java

@Override
public ArrayList<ContentProviderOperation> parse(ArrayList<JSONArray> entries, ContentResolver resolver)
        throws JSONException {
    final ArrayList<ContentProviderOperation> batch = Lists.newArrayList();
    final HashMap<String, ContentProviderOperation> blockBatchMap = Maps.newHashMap();
    final HashMap<String, ContentProviderOperation> sessionUpdateBatchMap = Maps.newHashMap();

    int nrEntries = 0;
    for (JSONArray schedules : entries) {
        Log.d(TAG, "Retrieved " + schedules.length() + " schedule entries.");
        nrEntries += schedules.length();

        for (int i = 0; i < schedules.length(); i++) {
            JSONObject schedule = schedules.getJSONObject(i);

            final long startTime = ParserUtils.parseDevoxxTime(schedule.getString("fromTime"));
            final long endTime = ParserUtils.parseDevoxxTime(schedule.getString("toTime"));
            final String kind = schedule.getString("kind");

            final String blockId = Blocks.generateBlockId(kind, startTime, endTime);

            if (!blockBatchMap.containsKey(blockId)) {
                final Uri blockUri = Blocks.buildBlockUri(blockId);

                ContentProviderOperation.Builder builder;
                if (isRowExisting(Blocks.buildBlockUri(blockId), BlocksQuery.PROJECTION, resolver)) {
                    builder = ContentProviderOperation.newUpdate(blockUri);
                } else {
                    builder = ContentProviderOperation.newInsert(Blocks.CONTENT_URI);
                    builder.withValue(Blocks.BLOCK_ID, blockId);
                }//from www .jav  a2s .  c o  m
                builder.withValue(Blocks.BLOCK_START, startTime);
                builder.withValue(Blocks.BLOCK_END, endTime);

                final String type = schedule.getString("type");
                final String code = schedule.getString("code");

                if (code.startsWith("D10")) {
                    builder.withValue(Blocks.BLOCK_TITLE, type.replaceAll("\\ \\(.*\\)", ""));
                } else {
                    builder.withValue(Blocks.BLOCK_TITLE, schedule.getString("code"));
                }

                builder.withValue(Blocks.BLOCK_TYPE, kind);
                blockBatchMap.put(blockId, builder.build());
            }

            if (schedule.has("presentationUri")) {
                final Uri presentationUri = Uri.parse(schedule.getString("presentationUri"));
                final String sessionId = presentationUri.getLastPathSegment();
                final Uri sessionUri = Sessions.buildSessionUri(sessionId);

                if (isRowExisting(sessionUri, SessionsQuery.PROJECTION, resolver)) {
                    String roomId = null;
                    if (schedule.has("room")) {
                        final String roomName = schedule.getString("room");
                        Cursor cursor = resolver.query(Rooms.buildRoomsWithNameUri(roomName),
                                RoomsQuery.PROJECTION, null, null, null);
                        if (cursor.moveToNext()) {
                            roomId = cursor.getString(RoomsQuery.ROOM_ID);
                        }
                        cursor.close();
                    }
                    final ContentProviderOperation.Builder builder = ContentProviderOperation
                            .newUpdate(sessionUri);
                    builder.withValue(Sessions.BLOCK_ID, blockId);
                    builder.withValue(Sessions.ROOM_ID, roomId);
                    if (schedule.has("note")) {
                        final String note = schedule.getString("note");
                        if (note != null && note.trim().length() > 0) {
                            builder.withValue(Sessions.NOTE, note.trim());
                        }
                    }

                    sessionUpdateBatchMap.put(sessionId, builder.build());
                }
            }
        }
    }

    batch.addAll(blockBatchMap.values());
    batch.addAll(sessionUpdateBatchMap.values());

    if (isRemoteSync() && nrEntries > 0) {
        for (String lostId : getLostIds(blockBatchMap.keySet(), Blocks.CONTENT_URI, BlocksQuery.PROJECTION,
                BlocksQuery.BLOCK_ID, resolver)) {
            if (!lostId.startsWith("lab")) {
                final Uri lostBlockUri = Blocks.buildBlockUri(lostId);
                batch.add(ContentProviderOperation.newDelete(lostBlockUri).build());
            }
        }
        for (String lostId : getLostIds(sessionUpdateBatchMap.keySet(), Sessions.CONTENT_URI,
                SessionsQuery.PROJECTION, SessionsQuery.SESSION_ID, resolver)) {
            Uri deleteUri = Sessions.buildSpeakersDirUri(lostId);
            batch.add(ContentProviderOperation.newDelete(deleteUri).build());
            deleteUri = Sessions.buildTagsDirUri(lostId);
            batch.add(ContentProviderOperation.newDelete(deleteUri).build());
            deleteUri = Sessions.buildSessionUri(lostId);
            batch.add(ContentProviderOperation.newDelete(deleteUri).build());
        }
    }

    return batch;
}

From source file:at.bitfire.davdroid.resource.LocalGroup.java

/**
 * Marks all members of the current group as dirty.
 *//*from   w ww .j  a va 2s. com*/
public void markMembersDirty() throws ContactsStorageException {
    assertID();
    BatchOperation batch = new BatchOperation(addressBook.provider);

    for (long member : getMembers())
        batch.enqueue(new BatchOperation.Operation(ContentProviderOperation
                .newUpdate(
                        addressBook.syncAdapterURI(ContentUris.withAppendedId(RawContacts.CONTENT_URI, member)))
                .withValue(RawContacts.DIRTY, 1).withYieldAllowed(true)));

    batch.commit();
}