我知道我的 web 应用程序的 appcache 运行良好,因为我已经在 Chrome 上尝试过它,即使在适用于 Android 的 Chrome 上它也可以工作,但是从 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):外部/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) no such table: Origins 10-15 01:21:43.815: D/WebKit(14278): ERROR: 10-15 01:21:43.815: D/WebKit(14278): Application Cache Storage: failed to execute statement “DELETE FROM Origins”错误“没有这样的表: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) 没有这样的表:DeletedCacheResources21: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”错误“没有这样的表: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) 没有这样的表:DeletedCacheResources21: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”错误“没有这样的表: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) 没有这样的表:DeletedCacheResourcesD/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) 没有这样的表:DeletedCacheResourcesD/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 不工作 =/ 我做错什么了吗?谢谢!