Access local Android file via WebView Javascript

I am looking for an elegant way to access local files (on the phone or SD card) on an Android device from JavaScript running in WebView on an Android device.

I am loading a WebView with an html page from a device located in the resource folder. Along these lines, I believe that I can access any file in this resource folder from Javascript, but I can’t download anything from the SD card or phone. I know about addJavaScriptInterface, but I'm specifically trying to load images, so using this method will require some tweaking to transmit the B64 encoded image.

I am new to Android development and want to make sure that I don’t miss something obvious.

+3
source share
2 answers

You need to implement ContentProvider to map local files to uris.

+3
source

Source: https://habr.com/ru/post/1777068/


All Articles