Accessing images stored as assets

Ive got pictures as assets which I want to recall and substitute them as images

Ive downloaded the Taifun file extension r file block and Ive searched and searched and cannot work out how to do it.

Any help appreciated

the assets are read only
if you want to replace an image, first copy it to a directory of your choice to display it in your app and replace the image there

Taifun

When I press the button I get a message

Sorry. File to copy does not exist???

But it’s in the assets???

Now I’m really confused.

Any help appreciated

Thanks

tried this… nothing and it shows an error

blocks (70)

Change extSdCard to sdcard.

Did you read the tooltip text for .Copy:

Copy file.
Use this method to copy small files, for large files use the CopyAsync method instead. Prefix the filename with / (i.e. relative path) to copy a file on the SD card. For instance /myFile.txt will copy the file /mnt/sdcard/myFile.txt. To copy assets packaged with an application (also works for the Companion) start the fromFilename with // (two slashes). However you can’t copy files to the assets. If a fileName starts with file:/// you can specify a complete path to the file.

try

//cc_dim.jpg

and

/pictures/cc_dim.jpg

Ok, Thanks. At least it didnt complain.

blocks (73)

Ok, that worked but it replaced the original picture with NOTHING

Thanks

You switched to the .CopyAsync block, therefore you need to use the event block after copying. You may also need to edit your Imc_cc file path…

Will it work if I go back to a straight copy?

This works for me, for an image file called 384-hport.jpg

image

not for me… ? Still replaces the original pic with nothing

Now I get a Permission Denied Error

Did you give read/write permissions for external storage as indicated in the details for the file extension?

Description

This extension is related to the file component.
Required permissions: android.permission.READ_EXTERNAL_STORAGE, android.permission.WRITE_EXTERNAL_STORAGE

Hi, I read the file extension doc and didn’t see anything about permissions.

Please can you show me how to grant permissions

Thanks

(this will give both read and write permissions)

Now Im really getting annoyed.

It doesn’t complain but it STILL doesn’t insert the new picture

Q1. Sould I write kodular or AppInventor?

Q2. Is EXTERNAL storage correct?

What if I dont have an SD Card???

These blocks work for me in companion on Android 11 device

They do not work for a compiled app, because you have to feed the ASD to the storage location and the image path.

I have no idea what you are talking about…

I need it for a compiled app so what else do I need to do???

Im so lost :slight_smile:

Any help withe ASD

@Avraham_Yerachmielbenzvi in your response here…

I recognize that in your path, you have “kodular.” There was a name change back in 2018, however the folder name never got switched. Use “Makeroid” instead.

Android will rewrite your path without telling you…

Thank you, Ive just done it.
Lets see :slight_smile:

1 Like

This is all you need (Companion & APK):

Note: This will no longer work for new apps when Kodular targets Android 11 (Aug 2021) with Android ≥ 10.

1 Like