Problem with WebView caching result


Last Updated:

  1. diablo_sv21

    diablo_sv21 New Member This Topic's Starter

    Joined:
    Aug 21, 2010
    Messages:
    3
    Likes Received:
    0
    Hey all,

    This problem has been killing me for a few days, I've tried searching the web and so far I've come up with not much.

    I've got a widget which uses a WebView to load a page from a URL and read the contents of the page. The reason for the WebView is that I need to emulate the browser in order to get the page to display the content, a HttpGet won't get it back (reliably).

    None the less, at some point the WebView stops loading new content and appears to keep loading a cached page instead. In the code it appears to have gone to the web to get a new page but what is returned is old data.

    Those with the Android 2.2 build get a new button for applications in the settings area which allows them to clear the App Data. Doing this blows away whatever cached data the WebView is using and it starts to work again.

    So what I would like to do is programmatically blow this App Data away. Only problem is that I have no idea what data it is. I'm not explicitly make it anywhere in my app, the WebView control appears to be making it itself. Would anyone know what is going on here and how I can avoid it?

    I've turned all caching off (in every way), it had no effect.

    Code (Text):
    1.  
    2.         browser = new WebView(context);
    3.         browser.getSettings().setJavaScriptEnabled(true);
    4.         browser.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);
    5.         browser.setDrawingCacheEnabled(false);
    6.         browser.clearCache(true);
    7.         browser.addJavascriptInterface(new MyJavaScriptInterface(), "HTMLOUT");
    8.         browser.setWebViewClient(new TelstraWebViewClient());
    9.         browser.loadUrl(URL);
    10.  
    Cheers
     

    Advertisement

Share This Page

Loading...