Sometimes the browser's bookmarks may be used. You can use the following code to obtain the information.
Contentresolver = getcontentresolver (); cursor = contentresolver. query (browser. bookmarks_uri, browser. history_projection, whereclause, null, orderby); While string orderby = browser. bookmarkcolumns. visits + "DESC"; string whereclause = browser. bookmarkcolumns. bookmark + "= 1 ";
Orderby refers to the sorting method, and whereclause is the selection condition. In this way, you can obtain the bookmarks of the self-contained browser in Android.
Then, we can define three arraylists to store information obtained from the database.
listTitle = new ArrayList<String>(); listUrl = new ArrayList<String>(); listBitmap = new ArrayList<Bitmap>();
Traverse cursor and save the information to arraylist:
while(cursor!=null && cursor.moveToNext()){ listTitle.add(cursor.getString(cursor.getColumnIndex(Browser.BookmarkColumns.TITLE))); listUrl.add(cursor.getString(cursor.getColumnIndex(Browser.BookmarkColumns.URL))); byte[] b = cursor.getBlob(cursor.getColumnIndex(Browser.BookmarkColumns.THUMBNAIL)); if(b!=null){ listBitmap.add(BitmapFactory.decodeByteArray(b, 0, b.length)); }else{ listBitmap.add(((BitmapDrawable)(getResources().getDrawable(R.drawable.ic_launcher_browser))).getBitmap()); } }