【发布时间】:2012-10-04 22:49:14
【问题描述】:
我知道我的 web 应用程序的 appcache 运行良好,因为我在 Chrome 上尝试过它,即使在 Chrome for Android 上它也可以运行,但是从 webview 将它加载到我的 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) 没有这样的表: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) 没有这样的表:缓存 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): Application Cache Storage: failed to execute statement "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 无法正常工作 =/ 我做错了什么吗?谢谢!
【问题讨论】:
-
这仍然困扰着我,我只是找不到方法来完成这项工作。有什么建议?谢谢:)
-
只是猜测:尝试在
setAppCacheMaxSize(1024*1024*16)和setAppCachePath(appCachePath)之前调用setAppCacheEnabled(true)。另外:你用的是哪个安卓版本? -
@Alberto Elias 嗨,您是否设法找出缓存不起作用的原因?我有完全相同的问题
标签: android webview html5-appcache