我知道我的網絡應用程序的appcache很好用,因爲我已經在Chrome上嘗試過它,即使在Android上的Chrome瀏覽器上也能正常工作,但它不會在從webview中將它加載到我的Android應用中時。我有以下設置:Appcache在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);
但加載應用程序時,在logcat的我可以閱讀以下
10-15 01:21:43.815: E/SQLiteLog(14278): (1) no such table: CacheGroups 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 CacheGroups" error "no such table: 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) no such table: Caches 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 Caches" error "no such table: 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" error "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) no such table: DeletedCacheResources
很顯然應用程序緩存沒有工作= /難道我做錯了什麼?謝謝!
這仍然困擾着我,我不能找到一種方法,使這項工作。有什麼建議麼?謝謝:) –
只是猜測:嘗試在'setAppCacheMaxSize(1024 * 1024 * 16)'和'setAppCachePath(appCachePath)'之前調用'setAppCacheEnabled(true)'。此外:您使用的是哪個Android版本? –
@Alberto Elias您是否設法找出緩存不工作的原因?我有完全相同的問題 – turtleboy