Example usage for android.content ContentResolver update

List of usage examples for android.content ContentResolver update

Introduction

In this page you can find the example usage for android.content ContentResolver update.

Prototype

public final int update(@RequiresPermission.Write @NonNull Uri uri, @Nullable ContentValues values,
        @Nullable String where, @Nullable String[] selectionArgs) 

Source Link

Document

Update row(s) in a content URI.

Usage

From source file:com.carlrice.reader.fragment.EntryFragment.java

private void refreshUI(Cursor entryCursor) {
    if (entryCursor != null) {
        String feedTitle = entryCursor.isNull(mFeedNamePos) ? entryCursor.getString(mFeedUrlPos)
                : entryCursor.getString(mFeedNamePos);
        BaseActivity activity = (BaseActivity) getActivity();
        activity.setTitle(feedTitle);/* ww w.j a  va 2 s .  c  om*/

        byte[] iconBytes = entryCursor.getBlob(mFeedIconPos);
        Bitmap bitmap = BitmapFactory.decodeByteArray(iconBytes, 0, iconBytes.length);
        UiUtils.getFaviconPalette(bitmap, mToolbarPaletteListener);

        mFavorite = entryCursor.getInt(mIsFavoritePos) == 1;
        activity.invalidateOptionsMenu();

        // Listen the mobilizing task
        if (FetcherService.hasMobilizationTask(mEntriesIds[mCurrentPagerPos])) {
            showSwipeProgress();

            // If the service is not started, start it here to avoid an infinite loading
            if (!PrefUtils.getBoolean(PrefUtils.IS_REFRESHING, false)) {
                Application.context().startService(new Intent(Application.context(), FetcherService.class)
                        .setAction(FetcherService.ACTION_MOBILIZE_FEEDS));
            }
        } else {
            hideSwipeProgress();
        }

        // Mark the article as read
        if (entryCursor.getInt(mIsReadPos) != 1) {
            final Uri uri = ContentUris.withAppendedId(mBaseUri, mEntriesIds[mCurrentPagerPos]);
            new Thread(new Runnable() {
                @Override
                public void run() {
                    ContentResolver cr = Application.context().getContentResolver();
                    cr.update(uri, FeedData.getReadContentValues(), null, null);

                    // Update the cursor
                    Cursor updatedCursor = cr.query(uri, null, null, null, null);
                    updatedCursor.moveToFirst();
                    mEntryPagerAdapter.setUpdatedCursor(mCurrentPagerPos, updatedCursor);
                }
            }).start();
        }
    }
}

From source file:com.flym.dennikn.fragment.EntryFragment.java

private void refreshUI(Cursor entryCursor) {
    if (entryCursor != null) {
        String feedTitle = entryCursor.isNull(mFeedNamePos) ? entryCursor.getString(mFeedUrlPos)
                : entryCursor.getString(mFeedNamePos);
        BaseActivity activity = (BaseActivity) getActivity();
        activity.setTitle(feedTitle);/*w  ww  .jav a2  s.c o  m*/

        byte[] iconBytes = entryCursor.getBlob(mFeedIconPos);
        Bitmap bitmap = UiUtils.getScaledBitmap(iconBytes, 24);
        if (bitmap != null) {
            activity.getSupportActionBar().setIcon(new BitmapDrawable(getResources(), bitmap));
        } else {
            activity.getSupportActionBar().setIcon(null);
        }

        mFavorite = entryCursor.getInt(mIsFavoritePos) == 1;
        activity.invalidateOptionsMenu();

        // Listen the mobilizing task
        if (FetcherService.hasMobilizationTask(mEntriesIds[mCurrentPagerPos])) {
            showSwipeProgress();

            // If the service is not started, start it here to avoid an infinite loading
            if (!PrefUtils.getBoolean(PrefUtils.IS_REFRESHING, false)) {
                MainApplication.getContext()
                        .startService(new Intent(MainApplication.getContext(), FetcherService.class)
                                .setAction(FetcherService.ACTION_MOBILIZE_FEEDS));
            }
        } else {
            hideSwipeProgress();
        }

        // Mark the article as read
        if (entryCursor.getInt(mIsReadPos) != 1) {
            final Uri uri = ContentUris.withAppendedId(mBaseUri, mEntriesIds[mCurrentPagerPos]);
            new Thread(new Runnable() {
                @Override
                public void run() {
                    ContentResolver cr = MainApplication.getContext().getContentResolver();
                    cr.update(uri, FeedData.getReadContentValues(), null, null);

                    // Update the cursor
                    Cursor updatedCursor = cr.query(uri, null, null, null, null);
                    updatedCursor.moveToFirst();
                    mEntryPagerAdapter.setUpdatedCursor(mCurrentPagerPos, updatedCursor);
                }
            }).start();
        }
    }
}

From source file:com.tune.news.fragment.EntryFragment.java

private void refreshUI(Cursor entryCursor) {
    if (entryCursor != null) {
        String feedTitle = entryCursor.isNull(mFeedNamePos) ? entryCursor.getString(mFeedUrlPos)
                : entryCursor.getString(mFeedNamePos);
        BaseActivity activity = (BaseActivity) getActivity();
        activity.setTitle(feedTitle);/*from   w ww.j av a  2 s  . c  om*/

        byte[] iconBytes = entryCursor.getBlob(mFeedIconPos);
        Bitmap bitmap = UiUtils.getScaledBitmap(iconBytes, 24);
        if (bitmap != null) {
            activity.getSupportActionBar().setIcon(new BitmapDrawable(getResources(), bitmap));
        } else {
            activity.getSupportActionBar().setIcon(null);
        }

        mFavorite = entryCursor.getInt(mIsFavoritePos) == 1;
        activity.invalidateOptionsMenu();

        // Listen the mobilizing task
        if (FetcherService.hasMobilizationTask(mEntriesIds[mCurrentPagerPos])) {
            showSwipeProgress();

            // If the service is not started, start it here to avoid an infinite loading
            if (!PrefUtils.getBoolean(PrefUtils.IS_REFRESHING, false)) {
                MainApplication.getContext()
                        .startService(new Intent(MainApplication.getContext(), FetcherService.class)
                                .setAction(FetcherService.ACTION_MOBILIZE_FEEDS));
            }
        } else {
            hideSwipeProgress();
        }

        // Mark the article as read
        if (entryCursor.getInt(mIsReadPos) != 1) {
            final Uri uri = ContentUris.withAppendedId(mBaseUri, mEntriesIds[mCurrentPagerPos]);
            new Thread(new Runnable() {
                @Override
                public void run() {
                    ContentResolver cr = MainApplication.getContext().getContentResolver();
                    cr.update(uri, FeedData.getReadContentValues(), null, null);

                    // Update the cursor
                    Cursor updatedCursor = cr.query(uri, null, null, null, null);
                    updatedCursor.moveToFirst();
                    mEntryPagerAdapter.setUpdatedCursor(mCurrentPagerPos, updatedCursor);
                }
            }).start();
        }

        // Finally hide the progress bar
        hideSwipeProgress();
    }
}

From source file:com.viktorrudometkin.burramys.fragment.EntryFragment.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    if (mEntriesIds != null) {
        Activity activity = getActivity();

        switch (item.getItemId()) {
        case R.id.menu_star: {
            mFavorite = !mFavorite;/*from www . ja  v a  2s.  c  om*/

            if (mFavorite) {
                item.setTitle(R.string.menu_unstar).setIcon(R.drawable.rating_important);
            } else {
                item.setTitle(R.string.menu_star).setIcon(R.drawable.rating_not_important);
            }

            final Uri uri = ContentUris.withAppendedId(mBaseUri, mEntriesIds[mCurrentPagerPos]);
            new Thread() {
                @Override
                public void run() {
                    ContentValues values = new ContentValues();
                    values.put(EntryColumns.IS_FAVORITE, mFavorite ? 1 : 0);
                    ContentResolver cr = MainApplication.getContext().getContentResolver();
                    cr.update(uri, values, null, null);

                    // Update the cursor
                    Cursor updatedCursor = cr.query(uri, null, null, null, null);
                    updatedCursor.moveToFirst();
                    mEntryPagerAdapter.setUpdatedCursor(mCurrentPagerPos, updatedCursor);
                }
            }.start();
            break;
        }
        case R.id.menu_share: {
            Cursor cursor = mEntryPagerAdapter.getCursor(mCurrentPagerPos);
            if (cursor != null) {
                String link = cursor.getString(mLinkPos);
                if (link != null) {
                    String title = cursor.getString(mTitlePos);
                    startActivity(Intent.createChooser(
                            new Intent(Intent.ACTION_SEND).putExtra(Intent.EXTRA_SUBJECT, title)
                                    .putExtra(Intent.EXTRA_TEXT, link).setType(Constants.MIMETYPE_TEXT_PLAIN),
                            getString(R.string.menu_share)));
                }
            }
            break;
        }
        case R.id.menu_full_screen: {
            setImmersiveFullScreen(true);
            break;
        }
        case R.id.menu_copy_clipboard: {
            Cursor cursor = mEntryPagerAdapter.getCursor(mCurrentPagerPos);
            String link = cursor.getString(mLinkPos);
            ClipboardManager clipboard = (ClipboardManager) activity
                    .getSystemService(Context.CLIPBOARD_SERVICE);
            ClipData clip = ClipData.newPlainText("Copied Text", link);
            clipboard.setPrimaryClip(clip);

            UiUtils.showMessage(getActivity(), R.string.copied_clipboard);
            break;
        }
        case R.id.menu_mark_as_unread: {
            final Uri uri = ContentUris.withAppendedId(mBaseUri, mEntriesIds[mCurrentPagerPos]);
            new Thread() {
                @Override
                public void run() {
                    ContentResolver cr = MainApplication.getContext().getContentResolver();
                    cr.update(uri, FeedData.getUnreadContentValues(), null, null);
                }
            }.start();
            activity.finish();
            break;
        }
        }
    }

    return true;
}

From source file:com.viktorrudometkin.burramys.fragment.EntriesListFragment.java

public void markAllAsRead() {
    if (mEntriesCursorAdapter != null) {
        Snackbar snackbar = Snackbar//ww w  .jav a2s  .c om
                .make(getActivity().findViewById(R.id.coordinator_layout), R.string.marked_as_read,
                        Snackbar.LENGTH_LONG)
                .setActionTextColor(ContextCompat.getColor(getActivity(), R.color.light_theme_color_primary))
                .setAction(R.string.undo, new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        new Thread() {
                            @Override
                            public void run() {
                                if (mJustMarkedAsReadEntries != null && !mJustMarkedAsReadEntries.isClosed()) {
                                    ArrayList<Integer> ids = new ArrayList<>();
                                    while (mJustMarkedAsReadEntries.moveToNext()) {
                                        ids.add(mJustMarkedAsReadEntries.getInt(0));
                                    }
                                    ContentResolver cr = MainApplication.getContext().getContentResolver();
                                    String where = BaseColumns._ID + " IN (" + TextUtils.join(",", ids) + ')';
                                    cr.update(FeedData.EntryColumns.CONTENT_URI,
                                            FeedData.getUnreadContentValues(), where, null);

                                    mJustMarkedAsReadEntries.close();
                                }
                            }
                        }.start();
                    }
                });
        snackbar.getView().setBackgroundResource(R.color.material_grey_900);
        snackbar.show();

        new Thread() {
            @Override
            public void run() {
                ContentResolver cr = MainApplication.getContext().getContentResolver();
                String where = EntryColumns.WHERE_UNREAD + Constants.DB_AND + '(' + EntryColumns.FETCH_DATE
                        + Constants.DB_IS_NULL + Constants.DB_OR + EntryColumns.FETCH_DATE + "<="
                        + mListDisplayDate + ')';
                if (mJustMarkedAsReadEntries != null && !mJustMarkedAsReadEntries.isClosed()) {
                    mJustMarkedAsReadEntries.close();
                }
                mJustMarkedAsReadEntries = cr.query(mCurrentUri, new String[] { BaseColumns._ID }, where, null,
                        null);
                cr.update(mCurrentUri, FeedData.getReadContentValues(), where, null);
            }
        }.start();

        // If we are on "all items" uri, we can remove the notification here
        if (mCurrentUri != null && Constants.NOTIF_MGR != null && (EntryColumns.CONTENT_URI.equals(mCurrentUri)
                || EntryColumns.UNREAD_ENTRIES_CONTENT_URI.equals(mCurrentUri))) {
            Constants.NOTIF_MGR.cancel(0);
        }
    }
}

From source file:de.ub0r.android.callmeter.data.RuleMatcher.java

/**
 * Unmatch all logs./*from   www  . ja va2 s.  c  o  m*/
 *
 * @param context {@link Context}
 */
public static void unmatch(final Context context) {
    Log.d(TAG, "unmatch()");
    ContentValues cv = new ContentValues();
    final ContentResolver cr = context.getContentResolver();
    cv.put(DataProvider.Logs.PLAN_ID, DataProvider.NO_ID);
    cv.put(DataProvider.Logs.RULE_ID, DataProvider.NO_ID);
    // reset all but manually set plans
    cr.update(DataProvider.Logs.CONTENT_URI, cv,
            DataProvider.Logs.RULE_ID + " is null or NOT (" + DataProvider.Logs.RULE_ID + " = "
                    + DataProvider.NOT_FOUND + " AND " + DataProvider.Logs.PLAN_ID + " != "
                    + DataProvider.NOT_FOUND + ")",
            null);
    resetAlert(context);
}

From source file:org.cgnet.swara.fragment.EntryFragment.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    if (mEntriesIds != null) {
        Activity activity = getActivity();

        switch (item.getItemId()) {
        case R.id.menu_star: {
            mFavorite = !mFavorite;//from  ww w  .  j av a2  s .  c o  m

            if (mFavorite) {
                item.setTitle(R.string.menu_unstar).setIcon(R.drawable.rating_important);
            } else {
                item.setTitle(R.string.menu_star).setIcon(R.drawable.rating_not_important);
            }

            final Uri uri = ContentUris.withAppendedId(mBaseUri, mEntriesIds[mCurrentPagerPos]);
            new Thread() {
                @Override
                public void run() {
                    ContentValues values = new ContentValues();
                    values.put(EntryColumns.IS_FAVORITE, mFavorite ? 1 : 0);
                    ContentResolver cr = MainApplication.getContext().getContentResolver();
                    cr.update(uri, values, null, null);

                    // Update the cursor
                    Cursor updatedCursor = cr.query(uri, null, null, null, null);
                    updatedCursor.moveToFirst();
                    mEntryPagerAdapter.setUpdatedCursor(mCurrentPagerPos, updatedCursor);
                }
            }.start();
            break;
        }
        case R.id.menu_share: {
            Cursor cursor = mEntryPagerAdapter.getCursor(mCurrentPagerPos);
            String enclose = cursor.getString(mEnclosurePos);

            String temp = enclose.split("http://cgnetswara.org//audio/")[1];
            String audio_recording = temp.split("\\[")[0];

            // Creates a folder for the app's recordings
            String path_audio = Environment.getExternalStorageDirectory().getAbsolutePath();
            path_audio += "/CGNet_Swara";

            audio_recording = path_audio + "/" + audio_recording;
            File child = new File(audio_recording);

            if (child.exists()) {
                Log.e("enclose", "INSDIE" + audio_recording);

                t.send(new HitBuilders.EventBuilder().setCategory("Audio file shared.")
                        .setLabel(audio_recording).build());

                startActivity(Intent.createChooser(new Intent(Intent.ACTION_SEND).setType("audio/*")
                        .putExtra(Intent.EXTRA_STREAM, Uri.parse("file:///" + audio_recording))
                        .setType(Constants.MIMETYPE_TEXT_PLAIN), getString(R.string.menu_share)));
            }
            break;
        }

        }
    }

    return true;
}

From source file:co.nerdart.ourss.fragment.FeedsListFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.feed_list_fragment, container, false);

    mListView = (DragNDropExpandableListView) rootView.findViewById(android.R.id.list);
    mListAdapter.setExpandableListView(mListView);
    mListView.setFastScrollEnabled(true);
    mListView.setOnItemLongClickListener(new OnItemLongClickListener() {
        @Override/*  w w w  .  j  a  v  a  2s.  c  om*/
        public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
            String title = ((TextView) view.findViewById(android.R.id.text1)).getText().toString();
            Matcher m = Pattern.compile("(.*) \\([0-9]+\\)$").matcher(title);
            if (m.matches()) {
                title = m.group(1);
            }

            long feedId = mListView.getItemIdAtPosition(position);
            ActionMode actionMode;
            if (view.findViewById(R.id.indicator).getVisibility() == View.VISIBLE) { // This is a group
                actionMode = getActivity().startActionMode(mGroupActionModeCallback);
            } else { // This is a feed
                actionMode = getActivity().startActionMode(mFeedActionModeCallback);
            }
            actionMode.setTag(new Pair<Long, String>(feedId, title));

            mListAdapter.setSelectedFeed(feedId);
            return true;
        }
    });

    mListView.setAdapter(mListAdapter);

    mListView.setOnChildClickListener(new OnChildClickListener() {
        @Override
        public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition,
                long id) {
            mListAdapter.startFeedActivity(id);
            return false;
        }
    });

    mListView.setDragNDropListener(new DragNDropListener() {
        boolean fromHasGroupIndicator = false;

        @Override
        public void onStopDrag(View itemView) {
        }

        @Override
        public void onStartDrag(View itemView) {
            fromHasGroupIndicator = itemView.findViewById(R.id.indicator).getVisibility() == View.VISIBLE;
        }

        @Override
        public void onDrop(final int flatPosFrom, final int flatPosTo) {
            final boolean fromIsGroup = ExpandableListView.getPackedPositionType(mListView
                    .getExpandableListPosition(flatPosFrom)) == ExpandableListView.PACKED_POSITION_TYPE_GROUP;
            final boolean toIsGroup = ExpandableListView.getPackedPositionType(mListView
                    .getExpandableListPosition(flatPosTo)) == ExpandableListView.PACKED_POSITION_TYPE_GROUP;

            final boolean fromIsFeedWithoutGroup = fromIsGroup && !fromHasGroupIndicator;

            View toView = mListView.getChildAt(flatPosTo - mListView.getFirstVisiblePosition());
            boolean toIsFeedWithoutGroup = toIsGroup
                    && toView.findViewById(R.id.indicator).getVisibility() != View.VISIBLE;

            final long packedPosTo = mListView.getExpandableListPosition(flatPosTo);
            final int packedGroupPosTo = ExpandableListView.getPackedPositionGroup(packedPosTo);

            if ((fromIsFeedWithoutGroup || !fromIsGroup) && toIsGroup && !toIsFeedWithoutGroup) {
                new AlertDialog.Builder(getActivity()) //
                        .setTitle(R.string.to_group_title) //
                        .setMessage(R.string.to_group_message) //
                        .setPositiveButton(R.string.to_group_into, new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog, int which) {
                                ContentValues values = new ContentValues();
                                values.put(FeedColumns.PRIORITY, 1);
                                values.put(FeedColumns.GROUP_ID, mListView.getItemIdAtPosition(flatPosTo));

                                ContentResolver cr = getActivity().getContentResolver();
                                cr.update(FeedColumns.CONTENT_URI(mListView.getItemIdAtPosition(flatPosFrom)),
                                        values, null, null);
                                cr.notifyChange(FeedColumns.GROUPS_CONTENT_URI, null);
                            }
                        }).setNegativeButton(R.string.to_group_above, new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog, int which) {
                                moveItem(fromIsGroup, toIsGroup, fromIsFeedWithoutGroup, packedPosTo,
                                        packedGroupPosTo, flatPosFrom);
                            }
                        }).show();
            } else {
                moveItem(fromIsGroup, toIsGroup, fromIsFeedWithoutGroup, packedPosTo, packedGroupPosTo,
                        flatPosFrom);
            }
        }

        @Override
        public void onDrag(int x, int y, ListView listView) {
        }
    });

    return rootView;
}

From source file:com.flym.dennikn.fragment.EntryFragment.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    if (mEntriesIds != null) {
        Activity activity = getActivity();

        switch (item.getItemId()) {
        case R.id.menu_star: {
            mFavorite = !mFavorite;//from   w w w . java 2s .c o m

            if (mFavorite) {
                item.setTitle(R.string.menu_unstar).setIcon(R.drawable.rating_important);
            } else {
                item.setTitle(R.string.menu_star).setIcon(R.drawable.rating_not_important);
            }

            final Uri uri = ContentUris.withAppendedId(mBaseUri, mEntriesIds[mCurrentPagerPos]);
            new Thread() {
                @Override
                public void run() {
                    ContentValues values = new ContentValues();
                    values.put(EntryColumns.IS_FAVORITE, mFavorite ? 1 : 0);
                    ContentResolver cr = MainApplication.getContext().getContentResolver();
                    cr.update(uri, values, null, null);

                    // Update the cursor
                    Cursor updatedCursor = cr.query(uri, null, null, null, null);
                    updatedCursor.moveToFirst();
                    mEntryPagerAdapter.setUpdatedCursor(mCurrentPagerPos, updatedCursor);
                }
            }.start();
            break;
        }
        case R.id.menu_share: {
            Cursor cursor = mEntryPagerAdapter.getCursor(mCurrentPagerPos);
            if (cursor != null) {
                String link = cursor.getString(mLinkPos);
                if (link != null) {
                    String title = cursor.getString(mTitlePos);
                    startActivity(Intent.createChooser(
                            new Intent(Intent.ACTION_SEND).putExtra(Intent.EXTRA_SUBJECT, title)
                                    .putExtra(Intent.EXTRA_TEXT, link).setType(Constants.MIMETYPE_TEXT_PLAIN),
                            getString(R.string.menu_share)));
                }
            }
            break;
        }
        case R.id.menu_full_screen: {
            setImmersiveFullScreen(true);
            break;
        }
        case R.id.menu_copy_clipboard: {
            Cursor cursor = mEntryPagerAdapter.getCursor(mCurrentPagerPos);
            String link = cursor.getString(mLinkPos);
            ClipboardManager clipboard = (ClipboardManager) activity
                    .getSystemService(Context.CLIPBOARD_SERVICE);
            ClipData clip = ClipData.newPlainText("Copied Text", link);
            clipboard.setPrimaryClip(clip);

            Toast.makeText(activity, R.string.copied_clipboard, Toast.LENGTH_SHORT).show();
            break;
        }
        case R.id.menu_mark_as_unread: {
            final Uri uri = ContentUris.withAppendedId(mBaseUri, mEntriesIds[mCurrentPagerPos]);
            new Thread() {
                @Override
                public void run() {
                    ContentResolver cr = MainApplication.getContext().getContentResolver();
                    cr.update(uri, FeedData.getUnreadContentValues(), null, null);
                }
            }.start();
            activity.finish();
            break;
        }
        }
    }

    return true;
}

From source file:co.nerdart.ourss.fragment.FeedsListFragment.java

private void moveItem(boolean fromIsGroup, boolean toIsGroup, boolean fromIsFeedWithoutGroup, long packedPosTo,
        int packedGroupPosTo, int flatPosFrom) {
    ContentValues values = new ContentValues();
    ContentResolver cr = getActivity().getContentResolver();

    if (fromIsGroup && toIsGroup) {
        values.put(FeedColumns.PRIORITY, packedGroupPosTo + 1);
        cr.update(FeedColumns.CONTENT_URI(mListView.getItemIdAtPosition(flatPosFrom)), values, null, null);
        cr.notifyChange(FeedColumns.GROUPS_CONTENT_URI, null);

    } else if (!fromIsGroup && toIsGroup) {
        values.put(FeedColumns.PRIORITY, packedGroupPosTo + 1);
        values.putNull(FeedColumns.GROUP_ID);
        cr.update(FeedColumns.CONTENT_URI(mListView.getItemIdAtPosition(flatPosFrom)), values, null, null);
        cr.notifyChange(FeedColumns.GROUPS_CONTENT_URI, null);

    } else if ((!fromIsGroup && !toIsGroup) || (fromIsFeedWithoutGroup && !toIsGroup)) {
        int groupPrio = ExpandableListView.getPackedPositionChild(packedPosTo) + 1;
        values.put(FeedColumns.PRIORITY, groupPrio);

        int flatGroupPosTo = mListView
                .getFlatListPosition(ExpandableListView.getPackedPositionForGroup(packedGroupPosTo));
        values.put(FeedColumns.GROUP_ID, mListView.getItemIdAtPosition(flatGroupPosTo));
        cr.update(FeedColumns.CONTENT_URI(mListView.getItemIdAtPosition(flatPosFrom)), values, null, null);
        cr.notifyChange(FeedColumns.GROUPS_CONTENT_URI, null);
    }//  w  ww .  j  a  v a  2s .c o m
}