Android Question Load html to WebView

Stefano Di Chiano

Active Member
Licensed User
Hello,
I'm looking for a way of loading html code from a file in my files directory in a webview.
I looked up for a solution in the forum but none seems to work.
I tried both loadHtml adn loadUrl, using as argument of the sub File.DirAssets & "file.html", "file:///android_asset/file.html" and others.
I also tried WebView1.LoadUrl(File.GetUri(File.DirAssets,"yourfile.html")) but File.GetUri doesn't show up.
 

JohnC

Expert
Licensed User
Longtime User
You definitely want to only use the .LoadHTML and not LoadURL if you want to display a local html file.

Try this:
B4X:
webview.loadhtml(File.ReadString(File.DirAssets,"myfile.html"))
 
Upvote 0

JohnC

Expert
Licensed User
Longtime User
Do a forum search of "css webview" and it will show you how.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…