Tuesday, August 14, 2012

Load local HTML from assets in Android

We can load local HTML (under /assets folder) in WebView. 

Load local HTML from /assets

Modify from the former post Handle the Back button in WebView, to back in history

Create our local HTML, /assets/myweb.html. 
<!DOCTYPE html>



<meta charset="UTF-8">

<meta name="viewport" content="width=device-width; user-scalable=0;" />

<title>Android Coding</title>

It's a local html in /assets.<br/>
Visit <a href="http://android-coding.blogspot.com/?m=1">Android Coding</a>



Load the local HTML in Java code: 

 final String DEFAULT_URL = "file:///android_asset/myweb.html";


No comments:

Post a Comment