File exist in the asset

Hi,
i need to know if a specified file is present in the asset directory like the example below. The file is present but the result is always false.
I have tried whit di prefix “\” or “//” but the result is the same.
Can anyone help me?
fileexixt

Try this /Makeroid/assets/your_file

image

1 Like

You are the only one who can upload assets into your apk.
So why do you need to check if it exists?
Sense?

If you did not added any into your assets then there are none

3 Likes

I have lot of galleries like this:
gal1:
-gal1img1
-gal1img2

gal2:
-gal2img1
-gal2img2

I can upload photos, delete it etc. i i do not want count everitime how much photos i have in the asset. With file exist dinamically i can populate the list :wink:

Hi dora_paz,
in Kompanion your solution work fine but when a create apk and test fileexist i obtain FALSE :frowning:
I tried to use a if condition where with develop=true use “/Makeroid/assets/1.jpg” while when develop=false use “//1.jpg” but the result is always false.
Any suggestion?

In this post…

there is a block: ListAllAssets that gets a list of assets files when the app is installed.

1 Like

Try this

image

this will work only in the companion app, but not anymore after building the app

the file extension offers the method FileListFromAssets
https://puravidaapps.com/file.php
Note: in Kodular this works only after building the app, see here why
filelistFromAssets

Taifun

2 Likes

Yes, this is also a bug with the File component. This path doesn’t work:
grafik
there is no path to access the assets so far.

I reported this also several times.
See here (point 4):


@Mika is / was working on it:

2 Likes

With the next release it should be possible too to check if a asset file exist.
No matter if companion or real apk.

It will work then with two // (slashes) at the start to tell the code it’s a asset file check.

4 Likes

tried but not all file are listed:

What is the extension of the files that are not listed?

.jpg image

That block works when the app is installed.
If you want to see the list of files in assets while you are in emulation (COMPANION), check:
http://kio4.com/appinventor/278_extension_shell.htm

Terminal.Run — commandLine: ls -al /mnt/sdcard/Makeroid/assets/

or

ls /mnt/sdcard/Makeroid/assets/

for now i have solved with dora-paz solution when the app run in companion
and [juananton1991] solution when the app is installed.

Thank you

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.