In emulator (i use genymotion) it works fine, but when I run it on a real device (my phone is ASUS ZenFone Laser 5.0) throws a filenotfoundexception
java.io.
I suspect WRITE_EXTERNAL_STORAGE
overrides the READ_EXTERNAL_STORAGE
read permission. If you look into the documentation you'll see that the former also permits reading from storage.
Try and remove the android:maxSdkVersion
attribute and see if that works. I suspect that your device runs an SDK version > 18.
Check out this answer for more info: https://stackoverflow.com/a/15270626/425238
you have to request permission before you start your instructions because this permission is considered dangerous in Marshmallow:
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M &&
checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED)
{
requestPermissions(new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, RESULT);
}
else
{
//your code
}