默認(rèn)情況下,localStorage在安卓webview中不生效,因?yàn)闆](méi)有設(shè)置緩存
對(duì)webview增加如下設(shè)置,可以讓localStorage生效:
//使用緩存,否則localstorage等無(wú)法使用
settings.setDomStorageEnabled(true);
settings.setAppCacheMaxSize(1024*1024*8);
String appCachePath = getApplicationContext().getCacheDir().getAbsolutePath();
settings.setAppCachePath(appCachePath);
settings.setAllowFileAccess(true);
settings.setAppCacheEnabled(true);