WebView: Load file from file.DirInternal

manios

Active Member
Licensed User
Longtime User
Hi all,

Loading from the assets directory works OK

WebView1.LoadUrl("file:///android_asset/help.html"

but how can I load a file from the .DirInternal?
 

Sarah

Member
Licensed User
Longtime User
Is there a way to structure a file path so as to use LoadUrl for a file in DirInternal?
The problem with loading html as text seems to be that relative links do not work.

e.g. if you have a file called "help.html" in DirInternal and a file called "help.css" also in DirInternal then "help.html" does not see the "help.css" file, presumably because it is loaded without knowing its own file path.
 
Upvote 0

warwound

Expert
Licensed User
Longtime User
Can you try something like this:

B4X:
WebView1.LoadUrl(File.Combine(File.DirInternal, "my_webpage.html"))

Martin.
 
Upvote 0

Sarah

Member
Licensed User
Longtime User
Thanks Martin but that didn't work.
This is what does:

B4X:
web.LoadUrl("file:///" & File.DirInternal & "/page.html")
 
Upvote 0

Sarah

Member
Licensed User
Longtime User
Both 2 slashes & 3 slashes works in my tests.
I haven't checked but I assume File.Combine returns a path starting with a slash, so that provides the third.
 
Upvote 0
Top