Search code examples
androidwebviewbrowser-history

getting WebView history from WebBackForwardList


How do i get the history of a WebView using the WebBackForwardList class? I looked at the documentation page but i could not understand it, is WebBackForwardList the proper way to access the history of WebView? I intend to parse the history to a ListView, I cannot find any examples of how to access the history of WebView, What is the proper method to get the history?


Solution

  • On your webView instance, just use copyBackForwardList(), for example

    WebBackForwardList wbfl = webView.copyBackForwardList();

    Then setup a for-loop to scan the list, pull entries (e.g., title, URL), and send them to your ListView (or whatever).