How can I create a new folder in the internal memory to save my file?

Hallo
How can i create a new folder in the internal memory to save my file.
For examble a will save my file in the folder "newfolder" which does not exist and I want it to be created.

When I do, it sends me an error message

Blockquote Error 2103: The file /storage/emulated/0/newfoder/file.txt could not be created

You can take advantage of this error. When this error occurs, use the file save block instead of adding to the file.

In the error event block, put the condition: if error = 2103 then save file - file.txt.

there is no easier way?

And is this method difficult? Append to file cannot create folders, so you need to create a folder and a file the first time.

For extension, see here.

Note: This won't work after AI2 is targeting API 30 (Android 11), Aug 2021. Then you have to use the ASD.

API < 29

https://puravidaapps.com/snippets.php#2dir by @Taifun

1 Like

Thanks you for your help

Ηow exactly do i do it? Can you write the Block code? I do not know exactly how to write it. I wrote it below but somewhere I am wrong

use the Screen.ErrorOccurred event to catch the error

Taifun


Trying to push the limits! Snippets, Tutorials and Extensions from Pura Vida Apps by icon24 Taifun.

I tried it, it does not show me the wrong message now but:

  1. I do not see anywhere the folder "newfolder" and file.txt
  2. Whatever number I put instead of 2103 again does the above.

What Android? Check if it creates a file without a folder: "/file.txt"

I tested it. It turns out that the file component cannot create folders. Use the extension @Anke pointed out.

After creating a folder, you may find that the AppendToFile Block may not create a file in the folder, if so use my method to create the file itself.

Unfortunately, the components aren't very advanced when it comes to file management.

Did I miss the memo about \n becoming a legal character in file names?

To create the folder without an extension on all Android versions (in the ASD):

See also here:

@Anke

Really? GetApiLevel1 and GetASD1 do not appear to be native Blocks.
ASD

Where do they come from? Something is missing?

I wrote

and this is correct, because this is done by the Canvas component (and not an ext.). GetASD only points to the ASD. This is also possible with this:

And GetApiLevel is also possible with this:

It always has been allowed, the Files app shows it as a space though.