How to pass html string to webview on android How to pass html string to webview on android android android

How to pass html string to webview on android


i have successfully done by below line

 //data == html data which you want to load String data = "Your data which you want to load"; WebView webview = (WebView)this.findViewById(R.id.webview); webview.getSettings().setJavaScriptEnabled(true); webview.loadData(data, "text/html; charset=utf-8", "UTF-8");

Or You can try

 webview.loadDataWithBaseURL(null, data, "text/html", "utf-8", null);


To load your data in WebView. Call loadData() method of WebView

webView.loadData(yourData, "text/html; charset=utf-8", "UTF-8");

You can check this example

http://developer.android.com/reference/android/webkit/WebView.html


Passing null would be better. The full codes is like:

WebView wv = (WebView)this.findViewById(R.id.myWebView);wv.getSettings().setJavaScriptEnabled(true);wv.loadDataWithBaseURL(null, "<html>...</html>", "text/html", "utf-8", null);