Mwebview = (webview) This. findviewbyid (R. id. webview); websettings settings = mwebview. getsettings (); settings. setjavascriptenabled (true); // settings. setpluginsenabled (true);/*** open the local cache and provide JS calls **/mwebview. getsettings (). setdomstorageenabled (true); // set cache size to 8 MB by default. shocould be more than enoughmwebview. getsettings (). setappcachemaxsize (1024*1024*8); // This next one is crazy. it's the default location for your app's cache // but it didn't work for me without this line. // update: No hardcoded path. thanks to Kevin Hawkins string appcachepath = getapplicationcontext (). getcachedir (). getabsolutepath (); mwebview. getsettings (). setappcachepath (appcachepath); mwebview. getsettings (). setallowfileaccess (true); mwebview. getsettings (). setappcacheenabled (true );
Java navtiveCodeYou only need to set the above parameters to provide local storage for the JS end. Remember that this parameter must be used by API> = 7, that is, android2.1 or later.