Android get system comes with browser bookmarks

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.