How to create directories in Android11

Viewed 215

I have tried many ways gone through many solutions but none of them are working.

I am trying to create a folder for my app in storage/emulated/0 but because of introduction of scoped storage in android 11, I guess I am not able to create the directory.

   <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
   <uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE"
    tools:ignore="ScopedStorage" />
   <uses-permission android:name="android.permission.ACCESS_MEDIA_LOCATION"/>

These are the permissions I have included in my AndroidManifest.xml and have set android:requestLegacyExternalStorage="true"

I also tried removing tools:ignore="ScopedStorage" from the MANAGE_EXTERNAL_STORAGE permission mentioned above.

When I am not including the MANAGE_EXTERNAL_STORAGE peremission this is the error I am getting:

FileSystemException: Creation failed, path = 'storage/emulated/0/myDir' (OS Error: Operation not permitted, errno = 1

And when I am including the MANAGE_EXTERNAL_STORAGE permission and asking for Permission.manageExternalStorage I am getting No permissions found in manifest for: []22

0 Answers
Related