ChPr
ChPr

Reputation: 7

I can't read/write on the external memory of my Galaxy A41

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

Answers (1)

ChPr
ChPr

Reputation: 7

I found the solution in this link. But I only access to the /storage/emulated/0. I have no access to my SD card.

Cordially.

Pierre.

Upvotes: 0

Related Questions