问题
Hello I tried to cache my web application with my android device. I tried everything but nothing will work. The Cache will not refresh only on android devices and not on other devices! Below you see all the settings I've set to cache the web application.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
web = (WebView) findViewById(R.id.webview);
web.setWebViewClient(new myWebClient());
web.getSettings().setJavaScriptEnabled(true);
web.getSettings().setCacheMode(web.getSettings().LOAD_NORMAL);
web.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY);
web.getSettings().setUserAgentString(getString(R.string.user_agent_suffix));
web.getSettings().setAppCachePath("http://192.168.0.62/lastversion/cache.manifest");
web.getSettings().setAllowFileAccess(true);
web.getSettings().setAppCacheEnabled(true);
web.getSettings().setDomStorageEnabled(true);
web.loadUrl("http://192.168.0.62/lastversion/");
}
here I set my cache:
<html manifest="cache.manifest">
I hope someone can help me. Thanks
回答1:
web.getSettings().setAppCachePath() set's the local directory where to store the cached files not where to load the manifest from.
The manifest has to be referenced in the HTML file you want to cache:
<html manifest="cache.manifest">
What do you mean with: "Cache will not refresh only on android devices and not on other devices!"
The cached files only will be updated if the content of the manifest has changed.
http://appcachefacts.info/
http://jonathanstark.com/blog/2009/09/27/debugging-html-5-offline-application-cache/
http://dev.opera.com/articles/view/offline-applications-html5-appcache/
来源:https://stackoverflow.com/questions/10800224/html5-cache-problems-with-android-webview