WebView Data Caching (Android)

  • I am loading HTML data into WebView using loadDataWithBaseURL
  • Do it one more time
  • Run the following code and instead of returning to the first page, all applications are terminated. What am I doing wrong here?

    public boolean onKeyDown(final int keyCode, final KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_BACK && this.browser.canGoBack()) {
        return true;
    return super.onKeyDown(keyCode, event);


Also - is it possible for the WebView cache to survive Activity # onStop? Basically - if I close the app and reopen it - I want the WebView to display the last data that was loaded, currently - I get a blank screen and then have to reload the same data again


source to share

1 answer

The problem is that load * doesn't create a new WebView and doesn't do anything special like creating a history entry.

You probably want to call startActivity () and call the second activity on the second dataset.



All Articles