2
<img src="file:///android_asset/www/images/image.png" style="border: black dashed 2px"/>

This line of code works as expected on a local html file.

However when you open an external url inside the app. (For example http://www.example.com/mobile/) The same line of code doesn't show an image.

To be clear, I am trying to access local files from an external url, because there are some JS files that are huge and It will be a waste of bandwidth to download them externally.

Kaan Soral
  • 1,589
  • 1
  • 15
  • 31

2 Answers2

1

The remote site will never be able to load an image from the file:// protocol.

Simon MacDonald
  • 23,253
  • 5
  • 58
  • 74
1

As @simon said u wont be able to load local assests on external url.. At best u can use loadDataWithBaseURL which will load your html with imgs/css/js from local assets folders something like this

webView.loadDataWithBaseURL("file:///android_res/raw/", html, 
                        "text/html", "UTF-8", null);
suraj jain
  • 1,012
  • 14
  • 26