Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5933627
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T14:59:59+00:00 2026-05-22T14:59:59+00:00

I try to reuse an existing WebView by clearing any private data the previous

  • 0

I try to reuse an existing WebView by clearing any private data the previous user left behind:

CookieManager.getInstance().removeAllCookie();
webview.clearHistory();
webview.clearFormData();
webview.clearCache(true);

clearHistory seems only to clear the back/forward list, accessible via API, but not the internal list used for coloring links inside the web content.

I even tried the following, suggested by another stackoverflow answer:

deleteDatabase("webview.db");
deleteDatabase("webviewCache.db");

I still have no luck: CSS :visited selectors still work after reloading the page.

An alternative would be to use the API level 11 private browsing feature (new constructor argument), but then I cannot benefit from visited links at all; and can no longer target older versions.

Maybe someone has a solution for this issue? Thanks for your help.

Summary of the answers I got so far:

I tried these two answers, but the first seems to clear HTML5 data storage and the latter seems to be specific to the built-in browser:

WebStorage.getInstance().deleteAllData();
Browser.clearHistory(getContentResolver());

WebChromeClient.getVisitedHistory(ValueCallback<String[]> callback) is only called after the first time I create a new WebView in a recently installed application.

I tried to remove the WebView from view hierachy and create a new one, but unfortunately the visited history seems to be stored for the whole application.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T14:59:59+00:00Added an answer on May 22, 2026 at 2:59 pm

    Override WebChromeClient and WebViewClient… Damn that was hidden.

    I actually had to dig up a bit to find this out.

    WebView webView = (WebView)findViewById(R.id.myWebView);
    WebChromeClient myWebChromeClient = new WebChromeClient(){
            @Override
            public void getVisitedHistory(ValueCallback<String[]> callback) {
    // called during webview initialization, original implementation does strictly nothing 
    // and defaults to the native method WebViewCore.nativeProvideVisitedHistory()
                String[] myUserHistory = getVisitedUrlsFromMyOwnDatabase(userId);
                callback.onReceiveValue(myUserHistory);
            }
        };
    WebViewClient myWebViewClient = new WebViewClient(){
        @Override
    public void doUpdateVisitedHistory(WebView view, String url,
            boolean isReload) {
    // called whenever there is a new link being visited
            insertIfNotExistVisitedUrlIntoMyOwnDatabaseForUser(userId);
            super(view, url, isReload);
    }
    }
    webView.setWebViewClient(myWebViewClient);
    webView.setChromeClient(myWebChromeClient);
    webView.getSettings().etc(whatever)...
    

    I think I’m “almost there”. Here’s the part I managed: what it does so far is remove css history altogether, so we’re halfway there. I can’t get the browser to recognize the url format I’m providing in “myUserHistory”, so in effect the only feature this code does is reset css history altogether, but it’s only called once when the WebView is instanciated (or created, didn’t check), so for a true multiuser experience you’d need to recreate the webview at each login.

    My problem now is that I can’t manage to load the urlHistory properly. My Honeycomb Xoom webview seems to ignore my data.
    Ah well, I hope it works for you. For me just calling callback.onReceiveValue(new String[]{}); in getVisitedHistory() will be good enough.

    EDIT:
    I just put twenty more minutes into it because I’m curious. This method is what delegates to the WebChromeClient (mCallbackProxy = WebChromeClient).

    protected void populateVisitedLinks() {
         ValueCallback callback = new ValueCallback<String[]>() {
             public void onReceiveValue(String[] value) {
                 sendMessage(EventHub.POPULATE_VISITED_LINKS, (Object)value);
             }
         };
         mCallbackProxy.getVisitedHistory(callback);
     }
    

    It’s protected in WebViewCore, which is a private attribute of WebView with no accessor. The sendMessage delegates to EventHub which is private, and WebViewCore is filled with private native methods, and one of these seems to be the one actually calling the populateVisitedLinks() method during the initialization.

    Unless someone at Google adds a public method to WebView to trigger the repopulation, I’m afraid it’s practically impossible to achieve your goal. Sorry 🙁

    As a side note, all these native visited history handling really makes me wonder: why do hardware manufacturers care so much about which urls we visited? 😉 <<< sarcasm

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Note: we reuse single connection. ************************************************ public Connection connection() { try { if ((connection
During a paint event, How can I reuse previous paintings so that I can
I am trying to reuse an existing code ... but with no success .
i try to reuse the lazyTableimages code but i got a problem that the
I am using a jquery mobile for mobile application, and I try to reuse
I'm trying to reuse an existing database connection so that I can do multiple
MSDN says that after CryptVerifySignature() you cannot reuse HCRYPTHASH object to try hashing more
I keep getting a Bad file descriptor error when I try to send data
I try to unify my layouts and so i want to reuse some UI
Try loading this normal .jpg file in Internet Explorer 6.0. I get an error

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.