Hello!
I want to edit a Bookmark using ContentValues(); I understand how to use this method in terms of updating the data (I think) but I'm missing the understanding on how I update the data of a specific ID.
//setting the URI (to edit the specific Bookmark by ID)
ContentValues bValues = new ContentValues();
bValues.put(Browser.BookmarkColumns._ID, bookmark_id);
Uri mUri = getContentResolver().insert(BOOKMARKS_URI, bValues);
//Using the mUri, edit the values of the Bookmark
ContentValues bEditValues = new ContentValues();
bEditValues.put(Browser.BookmarkColumns.TITLE, "NEW_TITLE");
bEditValues.put(Browser.BookmarkColumns.URL, "NEW_URL");
getContentResolver().update(mUri, bEditValues, null, null);
I get force close for Unknown URL (makes sense as I said, having trouble setting the editable Bookmark by ID):
E/AndroidRuntime(10031): FATAL EXCEPTION: main
E/AndroidRuntime(10031): java.lang.IllegalArgumentException: Unknown URL
E/AndroidRuntime(10031): at android.database.DatabaseUtils.readExceptionF
romParcel(DatabaseUtils.java:144)
E/AndroidRuntime(10031): at android.database.DatabaseUtils.readExceptionF
romParcel(DatabaseUtils.java:114)
E/AndroidRuntime(10031): at android.content.ContentProviderProxy.insert(C
ontentProviderNative.java:408)
E/AndroidRuntime(10031): at android.content.ContentResolver.insert(Conten
tResolver.java:587)
E/AndroidRuntime(10031): at com.droidil.droidmarks.Dmarks.editBookmark(Dm
arks.java:177)
E/AndroidRuntime(10031): at com.droidil.droidmarks.Dmarks.onContextItemSe
lected(Dmarks.java:139)
E/AndroidRuntime(10031): at android.app.Activity.onMenuItemSelected(Activ
ity.java:2199)
E/AndroidRuntime(10031): at com.android.internal.policy.impl.PhoneWindow$
ContextMenuCallback.onMenuItemSelected(PhoneWindow.java:2744)
E/AndroidRuntime(10031): at com.android.internal.view.menu.MenuItemImpl.i
nvoke(MenuItemImpl.java:143)
E/AndroidRuntime(10031): at com.android.internal.view.menu.MenuBuilder.pe
rformItemAction(MenuBuilder.java:855)
E/AndroidRuntime(10031): at com.android.internal.view.menu.MenuDialogHelp
er.onClick(MenuDialogHelper.java:137)
E/AndroidRuntime(10031): at com.android.internal.app.AlertController$Aler
tParams$3.onItemClick(AlertController.java:875)
E/AndroidRuntime(10031): at android.widget.AdapterView.performItemClick(A
dapterView.java:284)
E/AndroidRuntime(10031): at android.widget.ListView.performItemClick(List
View.java:3382)
E/AndroidRuntime(10031): at android.widget.AbsListView$PerformClick.run(A
bsListView.java:1696)
E/AndroidRuntime(10031): at android.os.Handler.handleCallback(Handler.jav
a:587)
E/AndroidRuntime(10031): at android.os.Handler.dispatchMessage(Handler.ja
va:92)
E/AndroidRuntime(10031): at android.os.Looper.loop(Looper.java:123)
E/AndroidRuntime(10031): at android.app.ActivityThread.main(ActivityThrea
d.java:4627)
E/AndroidRuntime(10031): at java.lang.reflect.Method.invokeNative(Native
Method)
E/AndroidRuntime(10031): at java.lang.reflect.Method.invoke(Method.java:5
21)
E/AndroidRuntime(10031): at com.android.internal.os.ZygoteInit$MethodAndA
rgsCaller.run(ZygoteInit.java:868)
E/AndroidRuntime(10031): at com.android.internal.os.ZygoteInit.main(Zygot
eInit.java:626)
E/AndroidRuntime(10031): at dalvik.system.NativeStart.main(Native Method)
Appreciate the help!