I am trying to read a file from the SD card, but finding that I don't have read permissions. I first get the public storage directory and list the files like so:
File dir = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS);
File[] files = dir.listFiles();
Then I select one of the files and test to see if it is readable:
Log.d(TAG, files[0].canRead());
This always displays false, and I'm not sure why. I am able to write to the directory (in fact it's the file that I've written that I want to read), and I've tried variations of
files[0].setReadable(true);
and
dir.setReadable(true);
with no luck. I also have
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
included in my Manifest file and made sure my device wasn't connected to anything (as suggested here), but that wasn't it.
I am able to pull the file from the device and read it in a text editor. Any ideas as to what this could be?
Stats: Using API 12 on Samsung Galaxy tablet.