'Android File.listFiles() not working for some directories

I have read/write/management permissions added to my manifest. Permissions are granted for my app. Most directories can be accessed just fine, but one is not.

    File test = new File("/storage/emulated/0/Pictures/aDirectory");

    boolean writable = test.canWrite();
    boolean readable = test.canRead();

writable and readable returns false so test.listFiles() returns null. Yet, the same directory can be accessed from another activity. Help please.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source