Android Webview上的Appcache未下载源

Android Webview上的Appcache未下载源,android,webview,html5-appcache,Android,Webview,Html5 Appcache,我知道我的web应用程序的appcache工作得很好,因为我在Chrome上试过,甚至在Android的Chrome上也试过,但在从网络视图加载到Android应用程序中时就不行了。我有以下设置: myWebView = (WebView) v.findViewById(R.id.webView); WebSettings webSettings = myWebView.getSettings(); webSettings.setDomStorageEnabled(tru

我知道我的web应用程序的appcache工作得很好,因为我在Chrome上试过,甚至在Android的Chrome上也试过,但在从网络视图加载到Android应用程序中时就不行了。我有以下设置:

    myWebView = (WebView) v.findViewById(R.id.webView);
    WebSettings webSettings = myWebView.getSettings();
    webSettings.setDomStorageEnabled(true);
    webSettings.setJavaScriptEnabled(true);
    webSettings.setSupportMultipleWindows(true);
    webSettings.setJavaScriptCanOpenWindowsAutomatically(true);
    webSettings.setAppCacheMaxSize(1024*1024*16);
    String appCachePath = getActivity().getApplicationContext().getCacheDir().getAbsolutePath();
    webSettings.setAppCachePath(appCachePath);
    webSettings.setAllowFileAccess(true);
    webSettings.setAppCacheEnabled(true);
    webSettings.setCacheMode(WebSettings.LOAD_DEFAULT);
    webSettings.setDatabaseEnabled(true);
    String databasePath = "/data/data/" + getActivity().getPackageName() + "/databases/";
    webSettings.setDatabasePath(databasePath);
    webSettings.setGeolocationEnabled(true);
    webSettings.setSaveFormData(true);
但是当加载应用程序时,在logcat中我可以看到以下内容

10-15 01:21:43.815:E/SQLiteLog(14278):(1)没有这样的表:缓存组 10-15 01:21:43.815:D/WebKit(14278):错误: 10-15 01:21:43.815:D/WebKit(14278):应用程序缓存存储:未能执行语句“从缓存组中删除”错误“无此类表:缓存组” 10-15 01:21:43.815:D/WebKit(14278):外部/WebKit/Source/WebCore/loader/appcache/ApplicationCacheStorage.cpp(558):bool WebCore::ApplicationCacheStorage::executeSQLCommand(const WTF::String&) 10-15 01:21:43.815:E/SQLiteLog(14278):(1)没有这样的表:缓存 10-15 01:21:43.815:D/WebKit(14278):错误: 10-15 01:21:43.815:D/WebKit(14278):应用程序缓存存储:未能执行语句“从缓存中删除”错误“无此类表:缓存” 10-15 01:21:43.815:D/WebKit(14278):外部/WebKit/Source/WebCore/loader/appcache/ApplicationCacheStorage.cpp(558):bool WebCore::ApplicationCacheStorage::executeSQLCommand(const WTF::String&) 10-15 01:21:43.815:E/SQLiteLog(14278):(1)没有这样的表:来源 10-15 01:21:43.815:D/WebKit(14278):错误: 10-15 01:21:43.815:D/WebKit(14278):应用程序缓存存储:未能执行语句“从源文件中删除”错误“无此类表:源文件” 10-15 01:21:43.815:D/WebKit(14278):外部/WebKit/Source/WebCore/loader/appcache/ApplicationCacheStorage.cpp(558):bool WebCore::ApplicationCacheStorage::executeSQLCommand(const WTF::String&) 10-15 01:21:43.815:E/SQLiteLog(14278):(1)没有这样的表:DeletedCacheResources


显然AppCache不工作了=/我做错什么了吗?谢谢

在appcache和domstore之前设置数据库, 在set*Enabled()之前设置任何“参数”,如set*Path()/set*Size()

除此之外,如果在使用时将两个独立管理的缓存堆叠在一起,可能不是一个好主意

getActivity().getApplicationContext().getCacheDir().getAbsolutePath()

作为webview的缓存管理器应存储其数据的目录

当活动的缓存管理器决定删除webview的缓存管理器创建的文件时,不会通知webview的缓存管理器,可能会进一步依赖该文件的存在


可能会工作很长时间,但有一天它可能会变成一个难以识别的交替错误这些是对我有用的设置:

CookieSyncManager.createInstance(contextForDialog);
webView = (WebView) findViewById(R.id.webView1);

WebSettings settings = webView.getSettings();

settings.setRenderPriority(RenderPriority.HIGH);
settings.setCacheMode(WebSettings.LOAD_DEFAULT);

settings.setSaveFormData(true);
settings.setLoadsImagesAutomatically(true);
settings.setJavaScriptEnabled(true);
settings.setDatabaseEnabled(true);
settings.setDomStorageEnabled(true);
settings.setAppCacheMaxSize(1024*1024*1024*8);
String sDataPath = context.getDir("database", Context.MODE_PRIVATE).getPath();
settings.setDatabasePath(sDataPath);
settings.setAppCachePath(sDataPath);
settings.setAllowFileAccess(true);
settings.setAppCacheEnabled(true);
settings.setAllowFileAccess(true);
settings.setGeolocationEnabled(true);
settings.setSavePassword(true);

webView.setFocusable(true);
webView.setFocusableInTouchMode(true);
settings.setDatabaseEnabled(true);
settings.setAllowContentAccess(true);
settings.setLoadsImagesAutomatically(true);
webView.addJavascriptInterface(this, "AndroidInterface");
WebView.setWebViewClient(new routeNavClient());
webView.setWebChromeClient(new webChromeClient());
CookieManager c = CookieManager.getInstance();
c.setAcceptCookie(true);

这仍然困扰着我,我只是找不到一个办法来让它工作。有什么建议吗?谢谢:)只是猜测:在
setAppCacheMaxSize(1024*1024*16)
setAppCachePath(appCachePath)
之前尝试调用
setAppCacheEnabled(true)
。此外:您使用的是哪一个Android版本?@Alberto Elias Hi您找到缓存不工作的原因了吗?我也有同样的问题