Alb*_*ias 5 android webview html5-appcache
我知道我的网络应用程序的appcache工作得很好,因为我已经在Chrome上尝试过,即使在Chrome for Android上也能正常运行,但是当它从我的Android应用程序从webview加载时却没有.我有以下设置:
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);
Run Code Online (Sandbox Code Playgroud)
但是在加载应用程序时,在logcat中我可以阅读以下内容
10-15 01:21:43.815:E/SQLiteLog(14278):( 1)没有这样的表:CacheGroups 10-15 01:21:43.815:D/WebKit(14278):错误:10-15 01:21:43.815 :D/WebKit(14278):应用程序缓存存储:未能执行语句"DELETE FROM CacheGroups"错误"无此表:CacheGroups"10-15 01:21:43.815:D/WebKit(14278):external/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)没有这样的table:Caches 10-15 01:21:43.815:D/WebKit(14278):错误:10-15 01:21:43.815:D/WebKit(14278):应用程序缓存存储:无法执行语句"DELETE FROM Caches"错误"没有这样的表:缓存"10-15 01:21:43.815:D/WebKit(14278):external/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):应用程序缓存存储:未能执行语句"DELETE FROM Origins"错误"no such table:Origins"10-15 01 :21:43.815:D/WebKit(14278):external/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不工作= /我做错了什么?谢谢!
小智 0
在appcache和domstore之前设置db,在set*Enabled()之前设置任何“参数”,例如set*Path()/set*Size()
除此之外,如果在使用时将两个独立管理的缓存堆叠在一起可能不是一个好主意
getActivity().getApplicationContext().getCacheDir().getAbsolutePath()
作为 webview 的缓存管理器应存储其数据的目录
当 Activity 的缓存管理器决定删除 Web 视图的缓存管理器创建的文件时,Web 视图的缓存管理器不会收到通知,并且可能进一步依赖它的存在
可能会持续很长时间,但有一天它可能会变成一个难以识别的交替错误
| 归档时间: |
|
| 查看次数: |
2931 次 |
| 最近记录: |