Reputation: 7
With Android studio, I installed this example on my smartphone.
At the first launch I have a message asking me if I allow the application to have access to the external memory. I answered yes.
On the second launch (or subsequent ones), using the debugger, I notice that the permission is granted and continuing the code, but when I reach the line:
FileOutputStream fos = new FileOutputStream(file);
it goes directly to:
} catch (Exception e) {
While I have permission, it doesn't work.
Doing the same manipulation, but using "run" instead of "debug", I get the following error (logcat):
2020-11-28 11:05:25.135 16779-16779/com.example.testrw D/path: /storage/emulated/0/UniqueFileName.jpg 2020-11-28 11:05:25.135 16779-16779/com.example.testrw W/System.err: java.io.FileNotFoundException: /storage/emulated/0/UniqueFileName.jpg: open failed: EACCES (Permission denied) 2020-11-28 11:05:25.135 16779-16779/com.example.testrw W/System.err: at libcore.io.IoBridge.open(IoBridge.java:496) 2020-11-28 11:05:25.136 16779-16779/com.example.testrw W/System.err: at java.io.FileOutputStream.(FileOutputStream.java:235) 2020-11-28 11:05:25.136 16779-16779/com.example.testrw W/System.err: at java.io.FileOutputStream.(FileOutputStream.java:186) 2020-11-28 11:05:25.136 16779-16779/com.example.testrw W/System.err: at com.example.testrw.MainActivity$1.onClick(MainActivity.java:47)
where line 47 is the one I mentioned:
FileOutputStream fos = new FileOutputStream(file);
This "run" shows a problem, but I don't see which one.
Please help me.
Cordially.
Pierre.
Upvotes: 1
Views: 92