Local HTML file for android

#1

Hi, any idea how do i target file:///android_asset for local HTML?

0 Likes

#2

hey, let me see if I understand: you have an html file you want to reference from another file? is this file on your apps filesystem or is it an asset saved in another folder?

in the first scenario, you can get file info using the FileSystem api

otherwise you should be able to require the file from its relative path in your project directory

0 Likes

#3

hi @samee thanks for reply,

actually im refering to webview component, i want it to load the HTML file inside my asset folder,

for IOS, it will be <WebView source={ require(’…/assets/generic.html’) } />
but for android it will be <WebView source={{ uri: ‘file:///android_asset/generic.html’ }} />

however, in expo case, it will be different, as we dont have android/app/src/main/assets folder, and I tried to create it manually, however it failed.

for more info, pls kindly refer to:
https://saumya.github.io/ray/articles/71/

0 Likes

#4

oh interesting, so the require syntax doesn’t work on android? what happens?

if you want, you could copy the file to somewhere on the apps FileSystem and reference it from there, but I’m wondering why the simple require wouldn’t work

1 Like

#5

I also not sure about why require not working :frowning:

do you have any example of copying it to filesystem?

thank you very much @samee

0 Likes