Files and folders

Until now i'am very happy with my App under Android 10.

But now i have to update to Android 11. So i have to work on the new File System.
I read a lot of things...and i'am more confused then before.

My App does the following things with files:

  • On Startup a Folder (LogFiles) is created in /storage/emulated/0
  • Files are written to this Folder
  • On Startup a folder "files" is created in ASD
  • On Startup a folder Webview is created in ASD/files
  • On Startup a file "index.html is copied from assets to ASD/files/Webview
  • with CustomWebView i open the index.html in ASD/files/Webview

is this also possible with Android 11?

Can i Create a folder in /storage/emulated/0?
Can i Create a Folder in ASD?

1 Like

You will have issues with the first two items on your list. You cannot create folders or files directly into /storage/emulated/0.

You will need to create the folder in your ASD and create the log files there. You can then copy these files to the Shared folders such as Download or Documents, these can be readable by other apps.

thank you.

The files should have easy access from Desktop PC.
So it would be ok to write them to ASD and copy to Documents.
But is it possible to create a folder in Documents?

It would be nice to have all files of my App separated in one Folder (without searching the ASD) to copy them to Desktop PC

No (at least not on Android 11+).

Yes.

So save / copy / move them to e.g. /Documents/myFolder/ or /Download/myFolder/.

1 Like

... you need to create this folder beforehand:

1 Like

I tried your example.

But it didn't work.
Folder in Documents is not created.
Folder in ASD is not created.
File is not copied to ASD.



Try this: FileTest.aia (2.1 KB)
Try with Companion & APK.
(Both should work.)

Blocks

But with the APK storage permissions are incorrectly required / requested.
This is a well known bug.
We are still waiting for a fix. :upside_down_face:

To avoid the permission request you have to use the FileTools extension from @vknow360.

i just tested the APK (not Companion).

i will test it with the extension. I think i used the same with Android 10

Fine, does it work for you?

no.
as i said: folders are not created and file not copied. And the is an error shown with File permissions

thats why i want to try the FileTools extension
did you have a link to the actua (working)l version?
i have version 9 already imported

You can download latest version from extension topic in Kodular Community.

My test app only creates the folders (but does not copy any file).
So again: Did you test my aia (FileTest.aia)?
I tested it with Android 9, 11, 12 (Companion & APK). It works on all devices.

Sorry Anke,
i misunderstood your question.

Your Example is working (tested as APP)

The Extension from @vknow360 is also working

I will try to get your example working in my App.If it's not working i have the extension as backup

FilesList does not work anymore.
known Bug?

Companion or APK?
If the app is uninstalled and reinstalled you can no longer list these non-media files, because they are created by another app (the uninstalled app).

(They must be created / saved again with different file names. Otherwise you have to use SAF.)

Try this aia (coming from Anke testfile), you can list only files saved from app.
DocFolderCreaList.aia (2.3 KB)

1 Like

Have a look to How to request and grant MANAGE_EXTERNAL_STORAGE permission
Be aware that this permission is usually not granted by Google. However, let’s assume the app is only intended for private use or for special users or for other app stores .

1 Like

ah yeah,
i copied the files with the desktop pc to the LogFiles folder
so if the files are copied with the App to this folder it will work?

But with Android 10 the files are also not listed?!

Yes, but you cannot overwrite / replace existing files, that were not created by the app. So you have to change the file names.

ok, i will try it