Anybody? Is this a bug in Android / Android Browser? On Jan 15, 10:32 pm, James G <jkg...@googlemail.com> wrote: > I have come across an awkward issue, and I would very much appreciate > your help to find out what I am doing wrong. > > I have an app which among other things allows users to edit bookmarks > in the Android Browser's bookmark store. It uses the > ContentResolver.query, .insert, .delete, and .update methods, with the > URI Browser.BOOKMARKS_URI. > > It all works well under Android 2, but on Androids 3 and 4 the .update > command does not appear to work. I have tried everything I can think > of, and just cannot make it work. > > To repeat this issue yourself in under one minute, create a new app > with an Activity named "BookmarkTestingActivity" and paste in the > source at the bottom of this post. Also add these two permissions to > the Manifest: > <uses-permission > android:name="com.android.browser.permission.READ_HISTORY_BOOKMARKS"/> > <uses-permission > android:name="com.android.browser.permission.WRITE_HISTORY_BOOKMARKS"/ > > > > This source simply inserts a new bookmark with title "Test" and url > "http://test.com", attempts to update the url to "http:// > updated.test.com", then Logs the url after that attempted change. > > In Android 2, the url correctly changes to "http://updated.test.com" > but in Androids 3 and 4 it remains at "http://test.com". The same > thing happens when I try updating other fields or using different > select variables etc. > > I'm testing with the latest SDK in Eclipse, on Android 2.3.3, Android > 3.1, and Android 4.0.3. > > I can work around the problem of course by doing a delete then another > insert, but that's not the point :) > > Thanks in advance! > > James. > > Source to repeat this issue: > ======================= > public class BookmarkTestingActivity extends Activity { > private static String LOGTAG = "BookmarkTesting"; > > public void onCreate(Bundle savedInstanceState) { > super.onCreate(savedInstanceState); > setContentView(R.layout.main); > > // Insert a new bookmark, with title "Test", and url "http:// > test.com". > ContentValues cv=new ContentValues(); > cv.put(Browser.BookmarkColumns.TITLE, "Test"); > cv.put(Browser.BookmarkColumns.URL, "http://test.com"); > cv.put(Browser.BookmarkColumns.BOOKMARK, "1"); > getContentResolver().insert(Browser.BOOKMARKS_URI, cv); > > // Update the url of all bookmarks with title "Test", to > "http:// > updated.test.com". > cv.clear(); > cv.put(Browser.BookmarkColumns.URL, > "http://updated.test.com"); > getContentResolver().update(Browser.BOOKMARKS_URI, cv, > BookmarkColumns.TITLE+"=?", new String[]{"Test"}); > > // Log out what the url is now. > Cursor cur = > this.getContentResolver().query(Browser.BOOKMARKS_URI, null, > BookmarkColumns.TITLE+"=?", new String[]{"Test"}, null); > if (cur == null) { > Log.e(LOGTAG, "Cursor null"); > } > else if (cur.getCount() == 0){ > Log.e(LOGTAG, "Cursor empty"); > } > else { > cur.moveToFirst(); > Log.e(LOGTAG, "URL is now > "+cur.getString(cur.getColumnIndex(BookmarkColumns.URL))); > } > > this.finish(); > } > > > > > > > > }
-- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en