WebView on Android 11 - not showing local image files

Viewed 1832

I have a problem with WebView on Android 11 (this worked under Android 10). The html

<img src='file:///storage/emulated/0/Android/data/<package>/image_cache/item_15.bmp'>

does not load the image. That html is part of a larger string. The image file was created by the same app and is valid.

What's changed?

1 Answers

Try setting webview.getSettings().setAllowFileAccess(true);. The documentation says:

The default value is true for apps targeting Build.VERSION_CODES.Q and below, and false when targeting Build.VERSION_CODES.R and above.

Related