I want get child list of /storage
directory by targetSdk=30
app.
So, I settings android.permission.MANAGE_EXTERNAL_STORAGE
permission to AndroidManifest.xml
and I created this code.
(I don't plan to distribute this app, so there is no problem granting this permission.)
<manifest>
...
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission
android:name="android.permission.MANAGE_EXTERNAL_STORAGE"
tools:ignore="ScopedStorage" />
...
</manifest>
Environment.getStorageDirectory().list() // return null
However, as comment in the code, this code will always return null...
Can you please help me?
(I'm not good at English, so going through a translation service. Sorry if it's not clear.)
I couldn't do it, so I used a different method.
The reason I wanted to get the list under /storage
was to detect an external SD card.
As an alternative, I implemented it to take the StorageManager
and fetch the directories for which isRemovable is true.
Thank you all for answers.