I have a WebView that I use to display some html / image files stored in the assets/ directory. I can have a WebView and html page load with:
mWebView.loadUrl("file:///android_asset/ContentRoot/SubDir/file.html");
or
String data = StaticFunctions.inputStreamToString(getAssets().open("ContentRoot/SubDir/file.html")); mWebView.loadDataWithBaseURL("file:///android_asset/ContentRoot/SubDir/file.html", data, "text/html", "UTF-8", null);
The problem I am facing is that there are images in HTML like:
<img src="../Photos/image.jpg" alt="whatever" />
and instead of loading from assets/ContentRoot/Photos/image.jpg he tries to load them from assets/Photos/image.jpg .
Why is he trying to download them from the wrong (relative) location and what can I do to fix the problem?
android webview assets
Jeremy logan
source share