Home > database >  Android Kotlin using WebView with android_asset
Android Kotlin using WebView with android_asset

Time:10-26

I'm using Android Studio Dolphin 2021.3.1

I have a WebView setup as follows:

val wb = WebView(this)
wb.loadUrl("file:///android_assets/html/About.html")
setContentView(wb)

I have an asset folder setup as follows:

[asset folder structure][1]

in the project disk location:

MyApp/app/src/main/assets/html

but when the WebView is displayed i get

net::ERR_FILE_NOT_FOUND

Can somebody suggest how i can access the files like this? do i have the location on disk wrong? [1]: https://i.stack.imgur.com/c5Ury.png

CodePudding user response:

Use url like this "file:///android_asset/html/About.html" with android_asset instead of android_assets

  • Related