Skip to content Skip to sidebar Skip to footer

Load Webview From Cache

I need to load the mWebview from internet when internet access is available. And when its not available it needs to load it from cache. I've got something but it doesnt load the si

Solution 1:

I've checked your code and the caching works fine (tested it with http://yahoo.com). Your problem must be in the isNetworkAvailable() method and thus the setCacheMode( WebSettings.LOAD_CACHE_ELSE_NETWORK) is not called.

To test this make isNetworkAvailable() return always false temporarily and put your device in Airplane mode after first loading the wepbage once.

Solution 2:

if ( !isNetworkAvailable() ) { // loading offline
    mWebview.getSettings().setCacheMode( WebSettings.LOAD_CACHE_ELSE_NETWORK );
style="color:red">}// move this bracket

mWebview.loadUrl("http://divers.ommelandercollege.nl/webportalen/dagrooster.php");
// to here  } 
}

Post a Comment for "Load Webview From Cache"