just took over a backup system browser bookmark module, now put the code out, there are a few questions please pass the Great God advice
1, according to the official API should be there are several fields are available
But in addition to the title and URL to get the other will be reported java.lang.IllegalStateException:Couldn ' t read row 0, col-1 from Cursorwindow. Make sure the Cursor was initialized correctly before accessing data from it. Exception
2. Is it possible to only get the system to bring your own browser bookmarks? If I have a Baidu or other browser built bookmarks are not going to get it?
Here's My Code snippet
/span>
Sort by access time string ORDER by = Browser.BookmarkColumns.VISITS + "DESC";//flag=1 means bookmark string whereclause = Browser.bookmarkcol Umns. BOOKMARK + "= 1"; Contentresolver CR = Context.getcontentresolver (); cursor cursor = cr.query (browser.bookmarks_uri,browser.history_projection, Whereclause, NULL, by-and-by), while (cursor!) = null && cursor.movetonext ()) {Bookmark bookmark = new Bookmark ();//TODO may be empty field//string id = cursor.getstring (c Ursor//.getcolumnindex (browser.bookmarkcolumns._id));//if (id! = NULL)//bookmark.set_id (ID);////string count = Cursor.getstring (Cursor//.getcolumnindex (Browser.bookmarkcolumns._count));//if (COUNT! = null)//bookmark.set_ Count (count); String title = cursor.getstring (Cursor.getcolumnindex (Browser.BookmarkColumns.TITLE)); if (title! = NULL) Bookmark.settitle (title); String url = cursor.getstring (Cursor.getcolumnindex (Browser.BookmarkColumns.URL)); if (URL! = null) Bookmark.seturl ( URL); byte[] B = Cursor.getblob (Cursor.getcolumnindex (Browser.BookmarkColumns.FAVICON)); if (b! = null) {Bookmark.setfavicon ((Bitmapfactory.decodebytearray (b, 0,b.length));} else {Bookmark.setfavicon (null);} Bookmark.setcreated (Cursor.getstring (Cursor//.getcolumnindex (Browser.BookmarkColumns.CREATED));// Bookmark.setdate (Cursor.getstring (Cursor//.getcolumnindex (Browser.BookmarkColumns.DATE)));//bookmark.setvisits (Cursor.getstring (Cursor//.getcolumnindex (Browser.BookmarkColumns.VISITS)));//bookmarks.add (BookMark); Bookmarks.add (BookMark);} Cursor.close (); Jsonobject JSO = Listtojsojsonobject (BookMarks); return jso.tostring ();
Android get system comes with browser bookmarks