Unable to find the good folder for the assets files

Hello,
I am trying to work with the tutorial about Webviewer using Javascript that has an usual
IF debugmode
use "Folder x"
else
use "folder y"
files folders
this is also shown in this topic.

However, either on debug mode or not I cannot access these files.
I always get "file not found " message.
Apparently my new Samsung A40 stores files differently than my previous mobiles.
But it is quite difficult to know what are the actual folders.
any idea?

Let us check where you are storing your file JavascriptProcessor.html.

Is this in your assets / Media ?

development path should be:

file:///mnt/sdcard/AppInventor/assets/JavascriptProcessor.html

compiled app path should be:

file:///android_asset/JavascriptProcessor.html

(you have an s on the end of android_asset)

other option is writing
file:///storage/emulated/0/folder_path for a file on internal storage and
file:///storage/emulated/sdcard/folder_path for file on SD card.

This:

or this

/storage/emulated/0/AppInventor/assets/JavascriptProcessor.html

needs file:// tacked on the front :slight_smile:

file:///storage/emulated/0/AppInventor/assets/JavascriptProcessor.html
2 Likes

for whatever reason ...

The webviewer requires a fully qualified url: http or https or file, for example.

... to complete this, these also seem to work:

file:/storage/emulated/0/AppInventor/assets/JavascriptProcessor.html

file:storage/emulated/0/AppInventor/assets/JavascriptProcessor.html

Btw, I would like to see the Java code to see how to get this:

The left paths work, the ones on the right (of course) don't.

1 Like

As written in documentation a file: URL is considered as local file URL but it is nowhere written that it should start with file:/ , file:// or file:///.
But it is recommended to use three slashes.(where path does not start with /)

1 Like

So what's your conclusion from this?

I ask, since you have a lot of experience with the WebViewer, because you have created an excellent CustomWebView extension.

Hi,
Thank you for all your responses.
Actually I tried this mtn/sdcard but it did not work.
I used the /storage/emulated/0/file_path and it worked on debug mode.
thanks for that.
the other part seems to work as well.
Thanks

Any url starting from file: is considered a local file url.
These all work:

However there is an exception. This will not work:

image

Same as what you have posted above.

Yes, but I cannot find out why these URLs (paths) are accepted or adapted so that you always get:
file: ///...

See here: appinventor-sources/appinventor/components/src/com/google/appinventor/components/runtime/WebViewer.java at master · mit-cml/appinventor-sources · GitHub

grafik

or in your CustomWebView extension:

grafik

Hello..
yesterday, I downloaded the HTML.aia from Taifun page and import it to appinventor and it was working great! it contains the following path:

file:///mnt/sdcard/AppInventor/assets/hello.html

Today I start to work on my project but this path not working any way!
I returned back to Taifun file and tried to run it but not working also! and I tried all possible paths described on this post and on other resources but no way!

I tried all paths here:
file:///storage/emulated/0/assets/hello.html
file:///storage/emulated/0/AppInventor/assets/hello.html
file:\\storage/emulated/0/AppInventor/assets/hello.html

but the following path worked for me when I built .apk and install it on my mobile!
file:///android_asset/hello.html

could any one help me please?

Thank you in advance!

for devices >= Android 10 the assets for the companion app are now stored in the ASD
in the webviewer you also can use the path http://localhost/hello.html now, which works in the companion app as well as after building

Taifun

Hi Taifun, Thank you for your assistance!
I already tried "http://localhost/hello.html" but no way!
check this here please


(external image uploaded into this thread by Taifun)

It would really help if you provided a screenshot of your relevant blocks, so we can see what you are trying to do, and where the problem may be.

To get an image of your blocks, right click in the Blocks Editor and select "Download Blocks as Image". You might want to use an image editor to crop etc. if required. Then post it here in the community.

Taifun


Trying to push the limits! Snippets, Tutorials and Extensions from Pura Vida Apps by icon24 Taifun.

..... and is hello.html stored in the ASD?