I'm trying to load a html string stored in the database which contain a image into a WebView
. The image is stored in the internal memory. I am giving a reference to the html string.But it doesn't work. Any help?
String content="<p>Can we have a rotational" +
" symmetry of order more than 1 whose angle of rotation is </p>\n" +
"\n <p>(i) <img alt=\"45\\degree\" src=\"file:///storage/emulated/01484890695248.jpg\" /></p>\n" +
"\n<p>(ii) <img alt=\"35\\degree\" src=\"file:///storage/emulated/01484890697301.jpg\" /></p>";
WebView00.loadDataWithBaseURL("", content, "text/html","UTF-8", "");
WebView00.getSettings();
Try like this
String base = Environment.getExternalStorageDirectory().getAbsolutePath().toString();
String imagePath = "file://"+ base + "/image_name.jpg";
String html = "<html><head></head><body> <img src=\""+ imagePath + "\"> </body></html>";
webView.loadDataWithBaseURL("", html, "text/html","utf-8", "");
Put the images in your assets
folder. Then use the corresponding prefix
file:///android_asset/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With