loading HTML with resources in application internal storage directory

My application tries to load a HTML string to webview. The HTML refers to an image file which is stored in the application internal storage directory "/data/data//files". The HTML is displayed, but a "broken link" image is displayed instead of the image. My code is like below

===============================================================================================

var myhtml = "<html> <body> <img src=\"Chrysanthemum.jpg\" alt=\"Chrysanthemum.jpg\" height=\"55\" width=\"55\" /> </body> </html>";

string baseURL = System.IO.Path.Combine("file://" + System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal) + "/");

webView.LoadDataWithBaseURL(baseURL, myhtml, "text/html", "UTF-8", null);_

===============================================================================================

If I store the file in the application "assets" folder and use "file:///android_assets/" as the baseURL, the image is displayed properly. Unfortunately my application downloads these images and cannot use them from assets folder.

Is anything wrong with this approach? Any help would be greatly appreciated.

PS. When I tried the same logic in Android native app (not Xamarin.android), the same baseURL loads the image properly.

Answers

Sign In or Register to comment.