How to show image from internal storage to webviewer?

I am creating an offline application where the user is allowed to download multiple images. Now I want to show the downloaded images into a single webviewer using html img tag. The main problem is that image is not shown in web viewer after downloading it into app’s specific directory. I think the problem is in the file_path I’m using to retrieve the file. (using file:///storage/emulated/0/Android/data/io.makeroid.companion/files/1.jpg).


(Here file path will return /storage/emulated/0/Android/data/io.makeroid.companion/files/1.jpg)

Please help me to solve my issue. Thank you!

try http://localhost/yourFilename.jpg
Edit 1: sorry, that answer only is correct for files stored in the assets of the app…

Edit 2: your path seems to be correct while using the companion app…
what happens if you try a relative path?
/Android/data/io.makeroid.companion/files/1.jpg

Taifun

1 Like

Thanks Taifun for your help but it didn’t work. After trying numerous methods, I finally got a solution.

I created a html file on the location where my images are downloaded. Then I displayed that html file on WebViewer. Then it showed the images.

I don’t know why its not working directly, maybe its not allowed to do directly or there is some problem in webviewer component.
Hope this solution will help someone who will be searching the community for the same question.

1 Like

great that you found a solution…
it might be, that the LoadHtml method is not able to display an image… is it a bug or a feature?
Taifun

I don’t know what it is. Same problem occurred when I tried to load JavaScript stored at internal storage. So to resolve this too, I had to create a html file with the JavaScript file location like (file:///storage/…), save it on the storage, finally display that html file. then it worked properly.

(I was using MathJax library of javascript)

I think that without having a html file saved at local storage, we couldn’t load any content from the storage devices through html codes.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.