the file:// url has been turned off as of api 30.
i think you can probably to turn it back on temporarily with webview extras 2.
the method is setfileallowaccess( true|false ).
enjoy it while it lasts. android doesn't want you to use it, which means you
will soon not be allowed to use it.
you can load your html this way, irrespective of api:
webview.loadhtml( file.readstring( file.dirinternal, "file.html" ))
there is a new, dedicated api to handle file:// type urls:
androidx.webkit.WebViewAssetLoader. my guess is after the complaining
dies down, it will ultimately be the only way to load a webview from a file on
one's device.
------------------------------------------------------------------------------------------------
UPDATE:
this is what assetloader looks like, and this is one example of how google wants you to do it:
webview.LoadUrl("https://appassets.androidplatform.net/assets/test.html")
i've tested it (both inline and as part of a library); it's easy to set up and works as expected.
but it would be cleaner if someone maintaining an important library here
(eg, webviewextras or even the core) were to include it there, rather than adding a random
inline snippet which ends up conflicting with such a library. (the assetloader api requires a
webviewclient. if you have a custom webviewclient, you nullify the webviewclient created
in, eg, webviewextras.)
EDIT:
if you don't need webviewextras then you're free to create your own and implement the
assetloader api.
even if you don't use webviewextras, our core webview provides functionality which is nullified
with a custom webviewclient. you would have to add those methods to your custom class if you
really wanted to use the webviewassetloader api and still use the standard webview.
for the purposes of a test, i only made a custom webviewclient. if google decides to do away
with file:// url's to load a webview, assetloader will be required.