Wu Wenjun
Wu Wenjun

Reputation: 137

All WebViews somehow shares visited history

I have multiple activities where I show different instances of WebViews. Lets say I visit www.stackoverflow.com in one activity. If I see a link that points to this adress, it will be shown in purple (showing that it has been visited). Now, I have tried clearing every WebView object in multiple ways, and in different stages (including after loading URL's for every WebView object). E.g., these are the functions I've tried calling for each WebView object:

Just after finding each layout element in my activities' onCreate (findViewById...), I am setting:

    wv.getSettings().setAppCacheEnabled(false);
    wv.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);

And then, in onPageFinished in my WebViewClient:

    wv.clearHistory();
    wv.clearCache(true);
    wv.clearFormData();
    wv.clearMatches();
    wv.clearSslPreferences();

I am only looking for some guidance on how to think on this matter, rather than a full code example. Hence, I do not provide full code for my specific case.

Edit:

Actually, if there is a way to clear a SPECIFIC website URL from an instance of a WebView, I would really prefer this.

I have tried overridding doUpdateVisitedHistory like this:

    @Override
    public void doUpdateVisitedHistory(WebView view, String url, boolean isReload) {
        super.doUpdateVisitedHistory(view, url, isReload);
        view.clearHistory();
    }

Upvotes: 1

Views: 512

Answers (0)

Related Questions