how to show the html contents to the webview using android

  1. Use web.loadDataWithBaseURL instead of web.loadData (And don’t forget to escape strings where it’s needed)
  2. You need to add internet permission to download images and view them in your manifest file.

This example works for me:

public class SimpleMusicStream extends Activity {
    public void onCreate(Bundle icicle) {

        WebView wv = (WebView) findViewById(;        

        final String mimeType = "text/html";
        final String encoding = "UTF-8";
        String html = "<br /><br />Read the handouts please for tomorrow.<br /><br /><!--homework help homework" +
                "help help with homework homework assignments elementary school high school middle school" +
                "// --><font color="#60c000" size="4"><strong>Please!</strong></font>" +
                "<img src=""  />";

        wv.loadDataWithBaseURL("", html, mimeType, encoding, "");


And don’t forget to add:

<uses-permission android:name="android.permission.INTERNET"></uses-permission>

in your AndroidManifest.xml file

Leave a Comment