Copy a file in another folder

Hello,
In an application, I want the user to choose an image from their device. Then I want to copy this image to an application specific folder.

How to copy a file without knowing the folder in advance ?

Source image: any folder (certainly a media subfolder)
Destination image: a specific app folder in a shared folder.
The selection of the image works because I use the image then in the background of the app


when I run the test I have an error "ERROR 1602 unable to copy selected media: ....."

If I look at the "ResultUri" return, I have some differences depending on what I choose the file with. Sometimes I don't have the name of the file but a number
Below is the return of "ResultUri"
"file:///storage/emulated/0/Android/data/edu.mit.appinventor.aicompanion3/files/data/content%3A/com.alphainventor.filemanager.fileprovider/root/storage/emulated/0/Pictures/HBTSV.png"

"file:///storage/emulated/0/Android/data/edu.mit.appinventor.aicompanion3/files/data/content%3A/0%40media/external/images/media/1708"
"file:///storage/emulated/0/Android/data/edu.mit.appinventor.aicompanion3/files/data/content%3A/com.android.providers.media.documents/document/image%253A1708"

"file:///storage/emulated/0/Android/data/edu.mit.appinventor.aicompanion3/files/data/content%3A/media/external/images/media/1708"

Thanks

best probably would be to use the SAF extension to be more flexible...
the file component only can access the shared directories and the user might want to choose a file from somewhere else...

Taifun

1 Like

Thanks for this extension
Even with that it doesn't work. I have looked at several example or request for help, but nothing works.
I also tried with your extension. It does not work.
I have the impression that the path is not suitable.
I spent too much time finding a solution, I will do it differently.
Thank you.

MANY THANKS ANKE !
I did not know the "PICK" for the activity starter. Where can we find all the possibilities?
The copy is done yessssss...
...But, not in the indicated path !!!
The file is copied directly to / Documents and not to / Documents / Gestion_Hand / Club
I'm doing a test to see if the folder exists and it's "True"

Have you an idea ?

I hadn't seen one thing:
The copied file is named Gestion_hand_club_HBTSV.png in the / Documents folder
while it must be called HBTSV.png in the Documents / Gestion_hand / club folder
I have the impression that he replaced the "/" by "_" at the copy
If we look at the results of the DO IT, everything is good, even the copy is true (but not in the right place). Strange!

I used TAIFUN's copy block and it works!

Have a happy new year and thank you for your help.

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