Html5 cache problems with android webview
Asked Answered
S

1

0

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

Sandi answered 29/5, 2012 at 13:32 Comment(0)
A
-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/

Assiut answered 27/7, 2012 at 8:19 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.