adryx_92
adryx_92

Reputation: 83

Read/write external storage on Android

I'm developing an Android application that reads and writes data in a /sdcard/MyFolder directory. I get the sdcard path trough the method Environment.getExternalStorageDirectory().

I tested the application on a Samsung device where the path returned by the method is /mnt/sdcard on which I append /MyFolder; all works fine and I can r/w files in this folder. Now I'm trying to do the same on a Nexus device: I have put my files to read in the /sdcard/MyFolder directory and getExternalStorageDirectory() returns /storage/emulated/0/ as path, on which I append /MyFolder. But in this case I cannot find the files to read.

I set all the storage permissions in the manifest.

Am I doing something wrong? Is there any particular issue related to an emulated directory?

Thanks

Upvotes: 0

Views: 1345

Answers (1)

SripadRaj
SripadRaj

Reputation: 1725

In Android 6.0, you have to handle certain permissions at runtime. Please go through this. Because READ_EXTERNAL_STORAGE and WRITE_EXTERNAL_STORAGE are considered as dangerous permissions and has to be handled at runtime.

Upvotes: 1

Related Questions