can i load local sdcard image file in to web view in android. If so how? I want to display that image file from sdcard on web view. How do i do it
Asked
Active
Viewed 5,530 times
0
-
possible duplicate of [Open Local Html File in Webview - Android](http://stackoverflow.com/questions/5812277/open-local-html-file-in-webview-android) – Nanne Apr 28 '11 at 06:01
3 Answers
0
You can get the sdcard path using -
"file:///" + Environment.getExternalStorageDirectory().getAbsolutePath() + "/";
and then use Webview 's loadData
to load the image
Salil
- 466
- 1
- 5
- 15
0
Here images is the name of the folder containing images
String imagePath = this.getFilesDir().getAbsolutePath() + "/images/";
if (!Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED))
{
Log.d("", "No SDCARD");
} else {
webView.loadUrl("file://"+imagePath+imageName);
}
kamal_tech_view
- 4,215
- 4
- 27
- 49
0
Try this:
String htmlContent = "<html><body><p><img src=\"file:///sdcard/image_name.jpg\" width=\"200\" height=\"133\" alt=\"\" /></p></body></html>";
webView.loadDataWithBaseURL("not_needed", htmlContent, "text/html", "utf-8", "not_needed");
Khai Nguyen
- 3,021
- 1
- 30
- 24