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:co.nerdart.ourss.adapter.FeedsCursorAdapter.java

public void setExpandableListView(DragNDropExpandableListView listView) {
    mListView = listView;//w  w w .j a  va2  s.com
    mListView.setDragNDropEnabled(feedSort);

    mListView.setOnGroupClickListener(new OnGroupClickListener() {
        @Override
        public boolean onGroupClick(ExpandableListView parent, View v, int groupPosition, long id) {
            Cursor cursor = getGroup(groupPosition);
            if (cursor.getInt(isGroupPosition) != 1) {
                startFeedActivity(id);
                return false;
            }

            ContentValues values = new ContentValues();
            if (mListView.isGroupExpanded(groupPosition)) {
                values.put(FeedColumns.IS_GROUP_COLLAPSED, true);
            } else {
                values.put(FeedColumns.IS_GROUP_COLLAPSED, false);
            }
            ContentResolver cr = mActivity.getContentResolver();
            cr.update(FeedColumns.CONTENT_URI(id), values, null, null);
            return false;
        }
    });
}

From source file:com.manning.androidhacks.hack023.dao.TodoDAO.java

public void modifyTodoFromServer(ContentResolver contentResolver, Todo list) {
    ContentValues cv = new ContentValues();
    cv.put(TodoContentProvider.COLUMN_TITLE, list.getTitle());
    cv.put(TodoContentProvider.COLUMN_STATUS_FLAG, StatusFlag.CLEAN);

    contentResolver.update(TodoContentProvider.CONTENT_URI, cv,
            TodoContentProvider.COLUMN_SERVER_ID + "=" + list.getId(), null);

}

From source file:net.fred.feedex.adapter.EntriesCursorAdapter.java

public void toggleFavoriteState(final long id, View view) {
    final ViewHolder holder = (ViewHolder) view.getTag(R.id.holder);

    if (holder != null) { // should not happen, but I had a crash with this on PlayStore...
        holder.isFavorite = !holder.isFavorite;

        if (holder.isFavorite) {
            holder.starImgView.setVisibility(View.VISIBLE);
        } else {//from w w  w. j  a  v  a 2s .  c  om
            holder.starImgView.setVisibility(View.INVISIBLE);
        }

        new Thread() {
            @Override
            public void run() {
                ContentValues values = new ContentValues();
                values.put(EntryColumns.IS_FAVORITE, holder.isFavorite ? 1 : 0);

                ContentResolver cr = MainApplication.getContext().getContentResolver();
                Uri entryUri = ContentUris.withAppendedId(mUri, id);
                cr.update(entryUri, values, null, null);
            }
        }.start();
    }
}

From source file:net.fred.feedex.adapter.EntriesCursorAdapter.java

public void toggleReadState(final long id, View view) {
    final ViewHolder holder = (ViewHolder) view.getTag(R.id.holder);

    if (holder != null) { // should not happen, but I had a crash with this on PlayStore...
        holder.isRead = !holder.isRead;//from   w w  w  .  ja  v  a 2 s.  c om

        if (holder.isRead) {
            holder.titleTextView.setEnabled(false);
            holder.dateTextView.setEnabled(false);
        } else {
            holder.titleTextView.setEnabled(true);
            holder.dateTextView.setEnabled(true);
        }

        new Thread() {
            @Override
            public void run() {
                ContentResolver cr = MainApplication.getContext().getContentResolver();
                Uri entryUri = ContentUris.withAppendedId(mUri, id);
                cr.update(entryUri,
                        holder.isRead ? FeedData.getReadContentValues() : FeedData.getUnreadContentValues(),
                        null, null);
            }
        }.start();
    }
}

From source file:com.grokkingandroid.sampleapp.samples.data.contentprovider.lentitems.LentItemDisplayFragment.java

/**
 * The dummyUpdate method is only used to show a sample update. 
 * It's not used within this sample app.
 *///from  www  . jav  a2  s  .  co  m
@SuppressWarnings("unused")
private long dummyUpdate() {

    String itemId = "10";
    String selection = LentItemsContract.SELECTION_ID_BASED; // BaseColumns._ID
                                                             // + " = ? "
    String[] selectionArgs = { itemId };
    ContentResolver resolver = getActivity().getContentResolver();
    ContentValues values = new ContentValues();
    values.put(Items.BORROWER, "Jane Doe");
    long updateCount = resolver.update(Items.CONTENT_URI, values, selection, selectionArgs);

    return updateCount;
}

From source file:com.jackie.movies.ui.DetailActivity.java

private void updateMark() {
    new Thread() {
        @Override/* w  w w.j  a  v  a  2s .  co m*/
        public void run() {
            super.run();
            synchronized (TAG) {
                ContentValues values = new ContentValues();
                boolean favour = detail.isFavour();
                values.put(MovieContract.Movie.FAVOUR, !favour);
                Uri uri = MovieContract.Movie.buildMovieUri(detail.getId());
                ContentResolver contentResolver = getContentResolver();
                int update = contentResolver.update(uri, values, null, null);

                if (update == 1) {
                    Message message = new Message();
                    message.what = WHAT_IS_CHECK_FAVOUR;
                    message.getData().putBoolean(EXTRA_FAVOUR, !favour);
                    handler.sendMessage(message);
                }
            }
        }
    }.start();
}

From source file:com.chatwing.whitelabel.managers.CommunicationModeManager.java

protected boolean updateChatBoxUnreadCountInDB(int chatBoxId, int unreadCount) {
    Uri uri = ChatWingContentProvider.getChatBoxWithIdUri(chatBoxId);
    ContentValues contentValues = new ContentValues();
    contentValues.put(ChatBoxTable.UNREAD_COUNT, unreadCount);

    ContentResolver contentResolver = mActivityDelegate.getActivity().getContentResolver();
    int updated = contentResolver.update(uri, contentValues, null, null);
    if (updated == 1) {
        mBus.post(new ChatBoxUnreadCountChangedEvent(chatBoxId));

        contentResolver.notifyChange(ChatWingContentProvider.getSyncedBookmarksUri(), null);
        contentResolver.notifyChange(ChatWingContentProvider.getAggregatedCategoriesUri(), null);
        contentResolver.notifyChange(ChatWingContentProvider.getCategorizedChatBoxesUri(), null);
        return true;
    } else {/*  w  w w. j ava2 s .  c  om*/
        LogUtils.e("Failed to update unread count.");
        return false;
    }
}

From source file:com.chatwingsdk.managers.CommunicationModeManager.java

protected boolean updateChatBoxUnreadCountInDB(int chatBoxId, int unreadCount) {
    Uri uri = ChatWingContentProvider.getChatBoxWithIdUri(chatBoxId);
    ContentValues contentValues = new ContentValues();
    contentValues.put(ChatBoxTable.UNREAD_COUNT, unreadCount);

    ContentResolver contentResolver = mActivityDelegate.getActivity().getContentResolver();
    int updated = contentResolver.update(uri, contentValues, null, null);
    if (updated == 1) {
        LogUtils.v("Update unread count. New Unread count: " + unreadCount);
        mBus.post(new ChatBoxUnreadCountChangedEvent(chatBoxId));

        contentResolver.notifyChange(ChatWingContentProvider.getAggregatedCategoriesUri(), null);
        return true;
    } else {//from   w w w.java2 s.co  m
        LogUtils.e("Failed to update unread count.");
        return false;
    }
}

From source file:net.naonedbus.manager.impl.FavoriManager.java

public void setFavori(final ContentResolver contentResolver, final Favori item) {
    final ContentValues values = getContentValues(item);
    contentResolver.update(FavoriProvider.CONTENT_URI, values, FavoriTable._ID + "=?",
            new String[] { String.valueOf(item.getId()) });
}

From source file:name.zurell.kirk.apps.android.rhetolog.RhetologApplication.java

@Override
public void onSessionRename(Context context, Uri session, String newName) {
    ContentResolver cr = getContentResolver();

    ContentValues values = new ContentValues();
    values.put(RhetologContract.SessionsColumns.TITLE, newName);

    cr.update(session, values, null, null);

}