HTML5 's offline application features enable WebApp to function even when the network is disconnected, which is a useful feature. In the recent work also wants to use HTML5 off-line application function, because is doing on the Android platform, therefore the natural choice webview to parse the webpage. But how to enable WEBIVEW support HTML5 off-line application function, after repeatedly groping and searching for information on the Internet, repeated to do the experiment finally succeeded. 
 
First you need to configure some of the properties of WebView, assuming that there is already a WebView instance object in the activity, named M_webview, and then add the following code: 
 
 
  
  Copy Code code as follows: 
 
 
  
 
  
  
WebSettings webseting = M_webview.getsettings (); 
  
Webseting.setdomstorageenabled (TRUE); 
  
Webseting.setappcachemaxsize (1024*1024*8)//Set buffer size, I set the 8M 
  
String Appcachedir = This.getapplicationcontext (). Getdir ("cache", Context.mode_private). GetPath (); 
  
Webseting.setappcachepath (Appcachedir); 
  
Webseting.setallowfileaccess (TRUE); 
  
Webseting.setappcacheenabled (TRUE); 
  
Webseting.setcachemode (Websettings.load_default); 
  
 
 
 
  
WebView can set a Webchromeclient object that responds to the expansion buffer in its onreachedmaxappcachesize function. The code is as follows 
 
 
  
  Copy Code code as follows: 
 
 
  
 
  
  
M_webview.setwebchromeclient (m_chromeclient); 
  
Private Webchromeclient m_chromeclient = new Webchromeclient () { 
  
Capacity to expand Cache 
  
@Override 
  
public void Onreachedmaxappcachesize (Long spaceneeded, 
  
Long Totalusedquota, Webstorage.quotaupdater quotaupdater) { 
  
Quotaupdater.updatequota (spaceneeded * 2); 
  
} 
  
}; 
  
 
 
 
  
Second, to modify the HTTP server configuration, so that it supports text/cache-manifest, I am using the Apache server, is the Windows version, in the Apache Conf folder to find Mime.types files, opened at the end of the file plus 
"Text/cache-manifest MF manifest", restart the server. This step is very important, because I did not configure this on the server side, so it failed many times, and finally the clue found in the reply to Appendix 1. 
After the above setup WebView can support the off-line application of HTML5. 
 
Appendix Link 1 says the buffer directory should be Getapplicationcontext (). Getcachedir (). GetAbsolutePath (); But I've been experimenting to find out that the directory doesn't work, maybe it's a different version of Android. Mine is Android4.0.3, and he's probably the previous Android version. 
 
The buffer directory uses Getapplicationcontext (). Getdir ("cache", Context.mode_private). GetPath () is a clue found in Appendix 2.