I am trying to get list of files existing in the Phone Pictures folder (internal storage, no SDCard inserted) using this:
File file = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES);
File[] files = file.listFiles();
but files value is always being null. I also add this to AndroidManifest.xml
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
Any ideas will be much appreciated, thanks in advance.
If you are targeting Android SDK >=23 you need to take permission at run-time.
https://developer.android.com/training/permissions/requesting.html
It returns null as Environment.getExternalStoragePublicDirectory
will/is supposed to handle files from external storage like SD card..as you are stating no sd card is inserted
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