android 中 webview 怎么用 localStorage?


我在 android里面 使用html5的 localStorage 
為什么存不進去也讀不出來呀?

網上搜了好多都沒效果

 

1
2
3
4
5
6
7
8
9
mainWebView = (WebView) this .findViewById(R.id.mainWebView);
         WebSettings settings = mainWebView.getSettings();
         settings.setJavaScriptEnabled( true );
         settings.setAllowFileAccess( true );
         settings.setDatabaseEnabled( true );
          String dir = this .getApplicationContext().getDir( "database" , Context.MODE_PRIVATE).getPath();  
         settings.setDatabasePath(dir);  
         settings.setDomStorageEnabled( true );
         settings.setGeolocationEnabled( true );

 

 

解決方案:

mWebView.getSettings().setDomStorageEnabled(true);   
mWebView.getSettings().setAppCacheMaxSize(1024*1024*8);  
String appCachePath = getApplicationContext().getCacheDir().getAbsolutePath();  
mWebView.getSettings().setAppCachePath(appCachePath);  
mWebView.getSettings().setAllowFileAccess(true);  

mWebView.getSettings().setAppCacheEnabled(true); 

這個測試了是可以的

 

轉自:http://www.oschina.net/question/111965_108361?sort=time


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM