In my android application need to detect cache is existed or not. Currently i am loading webpages if internet is available. If internet is not available loading pages from caches by using the following code.
if (networkInfo.isConnected()) {
webView.getSettings().setCacheMode(WebSettings.LOAD_DEFAULT); // load online by default
} else {
// loading offline
webView.getSettings().setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK);
}
In the above code i need to add one more condition for internet is not available and cache also not available then i need to show message to the user. So planning to identify any cache is available for webview. But unable to find a way to determine cache is available or not.
Have the following ideas but no idea how to achieve my goal. 1.Find out a method of weview or webviewsettings to return isCacheAvailable like method. Did not find it. 2.Find out the exact path for webview cache file. So that i can check the file size to determine the cache available or not. But did not find the way to get exact path for webview cache directory.
Please help me to find out a way to identify webview cache is existed or not.