Create new directory

Tried as is, or with “file:///” or with “file:///storage/emulated/0/”, but none of it worked. In the apk, I checked the permission, it was granted. Check online without much success.

To be exact, the apk created the directory correctly, but did not copy the files, while the companion, the directory was not created.

Can someone point me in the right direction. Thanks.

Screenshot (30)

hi @Donald_Hwong,
i’ll suggest you one thing that is don’t create directory as taifunfile will automatically create it.

just remove full location and directly give location. both the block given below… worked fine for me.

2 Likes

Thank you nikzdreamer2001. Your suggestion worked in the Companion mode, but not in the apk mode. Because the file that I need to copy over is in the “assets” of the apk. I suspect that “//filename.jpg” is the wrong format. Though that’s what TaiFun’s discussion stated so.

Any idea?

Use following extension
https://puravidaapps.com/tools.php

And in file from argument in taifunfiles use join text(2 text) in which first will be path to asset from above referenced extension and second argument will be filebane in assets.

after building the app, //filename.jpg will work
it does not work in the companion app because of

Taifun

Then I would like to suggest @Donald_Hwong to have a look here:

It works with Kodular and AI2 both.

1 Like

Dear Taifun and vknow360

Thank you again for your input for the second time. It was these same discussion that I’ve read before I created these blocks. The “companion” mode these blocks work. They just don’t work in the apk. The directory was not created and the file was not copied. I believe either I created Directory wrong, or the FileCopy.FromFileName is wrong.
I took Nikzdreamer2001’s advice and got rid of the AskPermission.ExternalStorage, and then put it back. With the storage permission granted, still no directory and no file copy.

I will also read the discussion suggested by vnow360.

Thank you all. I appreciated very much.
Thanks.

Hi @Donald_Hwong

As you have only shown blocks for companion so it is quite hard to find the problem.
Can we see your blocks for apk?

Thank you, vknow360. After I replace CreatDirectory with FileTools. Everything worked. However, I found another problem. I found out that all files are copied only after a second boot up. Meaning, once the permission are granted, when i query whether the permission was granted, the answer is negative. Only when I close the app and boot it up again the second time, then the directory is created and the files are copied over. Below are current blocks. My question is how do I code it, so that I can avoid a second boot up? Thank you.
Screenshot (31)

If I am not wrong then it is a bug in Kodular.I can be wrong.
This can be helpful:

And I am sure you will find a working solution there.

2 Likes

Haha, I was wrong, vknow360. After I replaced the original FileTool extension with the original File extension, it still worked. I now believe that the problem is caused by the storage permission query. I will read your discussion. For anyone who is interested to learn about my struggle. Below is the complete blocks for initiating copy files from assets to a mobile device upon installation.

2 Likes

Sounds good that you caught the real problem.
So we can close this topic?

After I implemented the When Screen1.PermissionGranted. Everything works. Thank everyone for helping out.

1 Like

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