Load html string into WebView in android

By | June 26, 2012

This sample code helps you to load html from a string and from a file into webview in ANDROID.

String str = Your HTML String;
/*
use src='file:///android_asset/images/photo_3.jpg' for loading images from
the assets /images folder
*/

/* To load from a string use loadDataWithBaseURL */
webview.loadDataWithBaseURL("",str , "text/html", "utf-8", "");

/* To load from a file use loadUrl(remote or local) */
webview.loadUrl("file:///android_asset/test.html");

2 thoughts on “Load html string into WebView in android

  1. Pingback: Load html string into WebView in android « tediscript.wordpress.com

  2. Pingback: new blog

Leave a Reply

Your email address will not be published. Required fields are marked *