1. Download our Official Android App: Forums for Android!

Apps Problem with WebView caching result

Discussion in 'Android Development' started by diablo_sv21, Sep 10, 2010.

  1. diablo_sv21

    diablo_sv21 Lurker
    Thread Starter

    Aug 21, 2010
    Analyst Programmer
    Melbourne, Australia
    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):
    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);


Share This Page