I used for B4A and B4I, the following code to load an image file from the AssetsDir in html in WebView.
wvwMain.LoadHtml(HtmlDocText)
HtmlDocText
...
<img src="${UrlForFileFromAssets(file.jpg)}"/>
...
I tried but failed with the following combinations:
How to build path string correctly ?
B4X:
Public Sub UrlForFileFromAssets(a_sFileName As String) As String
#If B4A
Return $"file:///android_asset/${a_sFileName}"$
#End If
#If B4i
Return a_sFileName
#End If
End Sub
wvwMain.LoadHtml(HtmlDocText)
HtmlDocText
...
<img src="${UrlForFileFromAssets(file.jpg)}"/>
...
I tried but failed with the following combinations:
B4X:
#If B4J
Return a_sFileName
#End If
#If B4J
Return $"file:///${a_sFileName}"$
#End If
#If B4J
Return $"file:///Files/${a_sFileName}"$
#End If
#If B4J
Return $"file:///{File.DirAssets}/${a_sFileName}"$
#End If
How to build path string correctly ?