0

For my android app I want to load a html file to webview like this

webview.loadDataWithBaseURL("file:///android_asset/", text ,mimeType, encoding, " ");

I am use this Data display webview nice but My Images not display in webview.

Question : Why my html images not display in webview?

This is screen shoot for webview Image not display Any one Have Idea tell me how to solve this.

enter image description here

EDIT: Here my Html data is Dynamic not static.And my images also not come in compile time come runtime only.

6
  • Are you loading images from the web...? if so than you can directly give image url to img src Commented Feb 20, 2013 at 5:56
  • something like this String html = "<h1>Header</h1><p>Custom HTML</p><p><img src=\\"file:///android_asset/image1.jpg\\" /></p>"; WebView wv = (WebView) findViewById(R.id.wv1); wv.loadDataWithBaseURL("fake://not/needed", html, mimeType, encoding, ""); Commented Feb 20, 2013 at 5:56
  • my all html data load in webview webview.loadDataWithBaseURL("file:///android_asset/", text ,mimeType, encoding, " "); here text is html String Commented Feb 20, 2013 at 5:58
  • Than don't specify MIME type directly use loadUrl Commented Feb 20, 2013 at 6:04
  • than how to use that one... Commented Feb 20, 2013 at 6:09

2 Answers 2

1

Try this code,it will work on all API levels..

webview.loadUrl("file:///android_asset/myfile.html");

Sign up to request clarification or add additional context in comments.

8 Comments

My html file is not static every search change my data.
how to store my data in specific file every time
you have to erase the data in the file and replace the data
iam asking how to html data store in that file in first time
Try this.. webview.loadDataWithBaseURL("notreal/", data_html, "text/htm", "utf-8",null);ref:stackoverflow.com/questions/5552578/…
|
0

I had the same problem because filenames are case sensitive.

So if you have image.PNG saved, make sure your html file references image.PNG rather than image.png.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.