Unable to create folder or unzip file into said folder

Hello everyone!
I’d like to start by appreciating how great this platform is, it’s helped speed up my production incredibly!

But – as the title leads – I’m having issues creating a folder, let alone extracting a zip file.

Here’s the section that handles the folder creation and zip extraction (ignore the error, I duplicated it as I was in a rush :joy:):

And here’s what I used to request permissions:

I’ve checked the permissions multiple times and tried calling it in so many different ways at different times in different screens, but it fails every time.
It seems to have permission however, according to the app permission info and after accepting the prompt.

Does anyone have an idea on a solution?
I’ve been cracking at this for days haha

To clarify, my goal is to create a folder in the home directory, then extract a downloaded zip file into the just created folder.

And here are the logs I’m getting, fetched from Android Studio:

  • When I try to create the folder
    Form DataDownload ErrorOccurred, errorNumber = 2108, componentType = File, functionName = MakeDirectory, messages = Cannot create directory at /storage/emulated/0/test
  • When I try to simply skip that process by manually creating the folder and just going straight to extracting:
    net.lingala.zip4j.exception.ZipException: Cannot create destination folder

1st check everything is working fine may b this happen due to your logic…
1st try to create an simple folder in ASD called App specific Directory use filescope as App directory and create an empty folder and check manually by Navigate to Android/data/pakjgname
with the help of your Device’s File manager
if its working then manualy put an simple .zip file in that folder and try to extract that zip… of both procedure is working then its all about storage permission…

You do not have access to the root directory of the emulated sdcard anymore… use ASD as @Professional suggested or use shared shorage, i.e. for example /Download/test

Taifun

1 Like

Thank you both for the response :slight_smile:
Just to clarify, I’m trying to create a folder in /storage/emulated/0/, is that the root directory you’re talking about?

My project depends on creating a directory there and unzipping that file, and I would’ve thought it was possible, even in Android 12…

And I’ll do some testing in the ASD!

Yes

As already suggested

See also Some basics on Android storage system

Taifun

don’t use root Directory directly bcz after android > 11 they put more securities on storage permissions…

Use ASD or root/download/your folder
as @Taifun suggested

The project installs an APK that literally relies on creating a folder in this directory, if I can’t do so, then this entire project has been for nothing haha. Just to clarify, the directory one level down from the Downloads folder to be absolutely clear, not Android > data / obb

And various applications such as ZArchiver, FileManager+ etc can all access this folder fine, so is this a restriction of Kodular?

To access the external storage, READ_ or WRITE_EXTERNAL_STORAGE permission is needed.

And I believe I have given my application these permissions via extensions.

And thank you both for the help, apologies if I’m coming across in a negative way :sweat_smile:

Well, this is not the root directory you were talking about previously, this is a subfolder of /Download what I suggested from the beginning of this thread

For example /Download/test
Or as full path /storage/emulated/0/Download/test

Note: it is /Download and not /Downloads

This is valid for older devices, for newer devices not anymore, see again Some basics on Android storage system

Taifun

One level *up, I’m so sorry for the miscommunication :sweat_smile:


I’m attempting the third one on the right.

And I see now that it R/W _EXTERNAL_STORAGE is for older devices, so would I need to have MANAGE_EXTERNAL_STORAGE?

And I’ve read through the Android Filesystem thread, as well as the Android Developer page a few times, I hope this correlates with what I’m trying to do.

if your app targets Android 11 (API level 30) or higher, the WRITE_EXTERNAL_STORAGE permission doesn’t have any effect on your app’s access to storage.

Android 11 introduces the MANAGE_EXTERNAL_STORAGE permission, which provides write access to files outside the app-specific directory

yes
however: do you plan to publish your app in Google Play?

Taifun

Thank you so much!
I do not plan to publish it, it’s going to be installed on devices without the Play Store anyway :slight_smile:

And it’s worked great, thank you thank you!

Here’s my finished code:
image

I requested android.settings.MANAGE_ALL_FILES_ACCESS_PERMISSION with Activity Starter, and this is working perfectly :blush:

Thank you both for the help, I can finally keep going!

1 Like