Create a folder and move a photo into it

I tried this, I don't really know how to use the Copy method because it says in the documentation that it is a boolean and I joined it in a conditional block without having much idea why. By the way, the link to Anke's tutorial is very good. I would be in the case of a microsd. I have tried several folder managers, but they have me a little confused because they say that the root of my microsd is /storage/6539-3263/ but if I go to the root of the file system, inside /storage there is only one folder, which is emulated/ I don't really know why?
Anyway, these are the blocks I have tried and the error I got:


blocks

Because your microsd is not in your device's root file system

I thought it would be mounted inside /storage or inside /mnt. In linux everything hangs on /.

Whilst I agree with you, android does not present it that way, and you can't see it in /storage/.

  1. You cannot save a file to a removable SDcard since Android 4.4 (API 19, KitKat).
  2. The File component requires a relative path (with DefaultFileScope to the ASD and with Legacy to the root directory of the external storage).
1 Like

I have Android 14 on my phone. Are you telling me that there is no way to save a file to the micro SD expansion card? Is it a limitation of Android or AppInventor? How do other apps do it? Because I have several that write their data there. Or do you have to request permission or take another route to do the task?

Anyway, are the blocks used correctly as I mentioned above to capture an image and save it to disk? When you take the photo, it is already saved to disk, right? It doesn't stay in RAM or something like that, right?

Thank you for your patience.

1 Like

No, as I said the File comp. needs/uses a relative path.

Thanks, Anke. Now it works by saving the image to the internal memory folder. Now I have another problem, when I compile to an APK, the path changes and it stops working, obviously. I notice that now the path includes my mobile user in its string, if I install it on a different mobile, it will have another user and it will not work. Is there any way to get the username to get around this problem?


In segment block there is: file:///storage/emulated/0/Android/data/edu.mit.appinventor.aicompanion3/files

i have the same problem :frowning:

any process here?

would make my day

Use the File component's Make FullPath block

image

instead of hard coding a companion file path

I tried this code from several code snippets. in the end it always says "false" and the zip function does not even start, so there is no folder created or file copied.

so what do i do wrong? i put some hours into but im still lost

You need to extract the filename from the filepath found in "image"

i thought i did at the notifier1-block. or do i missunderstand the "extract"?
the picture is shown on the button but the movefile-block does not work

  1. You cannot create a (sub)folder in the root directory of the external storage on Android 11+.

  2. You can only create a new subfolder in one of the Shared folders (like e.g. /Download or /Documents).

  3. The File component uses/needs a relative path (not an absolute path). With FileScope=App it is just the fileName. With FileScope=Shared or Legacy the path is relative to the root directory of the external storage (/storage/emulated/0).


See also here: Some basics on Android storage system

i dont get the point.

i guess everything is tecnicaly correct what u said, but i dont understand how to transform that into an action. what exactely shall i do in this case?

i am not too used to the app inventor topic and do not understand what i can do when u say p.e. 2) or 3) which blocks do i need to set?

i would tip you a coffe or so if you can help out :stuck_out_tongue:

Where do you want to move your photo files to ? the Test directory in your ASD (App), or somewhere in Shared Directories (Download/Documents/Pictures...)

  1. grafik
    /Pictures/Test

  2. Use the FileTools.Move method to move the image to /Pictures/Test in the Camera.AfterPicture event by using the "image" parameter (that is, the absolute or full path).

Tested in companion app 2.74u on Android 15
Camera images saved to ASD/Pictures, then moved to ASD/Test
Zip file created in ASD
Shared zip to Gmail without issue

The labels are simply to show what is happening, you can replace with variables as required.

Hi, realy thank you for the support!

finaly i've got it run, man this is something i have to go more into. for me its hard to understand but i guess i somehow see now what's the matter here.

thank you 2 for your help, my understanding now is much better and as a benefit the code is running too. nice

i'd like to tip you two a coffe or so if you have a button

thanks again and have a nice day