I am writing an android App. In the app I need access to the download directory \DOWNLOAD. I can read and write files within the app directory and I see the DOWNLOAD directory when I request the files within root directory. But when I use
File[] files = new File("\DOWNLOAD").listFiles();
the result is not a valid array but null.
I added
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
to the AndroidManifest.xml and I enabled the Storage permission on the phone.
What else must I do to get access to the files in download directory?
Kind regards, Wolfgang
It seems that adding
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
is not sufficient. Now I additionally request this permission on runtime with following code:
String[] requiredPermissions = { Manifest.permission.READ_EXTERNAL_STORAGE };
ActivityCompat.requestPermissions(this, requiredPermissions, 0);
and it works again :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With