I want to load an image in WebView in android, and I have:
public static final String URL_EMOTION_2 = "/sdcard/kingfisher_ph/e2.gif";
public static final String FILE = "file:/";
// Get the image url
String imagePath = FILE + URL_EMOTION_2;
If I use webView.loadUrl(imagePath); I can see the e2.gif loaded to screen. However, If I try to create an Html String and load to WebView:
String htmlString = "<html><head></head><body><img src=\"" + imagePath + "\" alt=\"My emotion\"/>"</body></html>";
webView.loadData(htmlString, "text/html", "utf-8");
The code above cannot load image, it show only My emotion String! What's wrong with my code? Thanks everyone!
Edit: Thanks, I solved the problem above with webView.loadDataWithBaseURL(...).
However, I have one more problem that occur when I want to reload my webView (because sometimes, I want to change htmlString and reload webView to show what changed), it usually start a blank web page!! How can I disable it? Or is there any other ways to refresh the webViewafter I change the htmlString intermadiately?