I want to save the image in the deviceβs photo catalog. I use
path = Environment.getExternalStoragePublicDirectory(
Environment.DIRECTORY_PICTURES);
After calling this method on my S3 (Android 4.3), the path contains "/ storage / emulated / 0 / Pictures". When I try to create a file in this directory, it works. I use
File.createTempFile(
imageFileName, ".jpg", path);
for this. I tested on the Galaxy S5 and on the emulator, as with Android 5.0. In the emulator, the path contains "/ storage / sdcard / Pictures". When I try to create a file in it, I get "java.io.IOException: open failed: ENOENT (There is no such file or directory)". My emulator supports SD card. S5 does not have an SD card. Perhaps this is the cause of the problem on the device. I use the permission WRITE_EXTERNAL_STORAGE in my manifest. I even tried using file.mkdirs () to ensure that the path exists. But this also does not work.
source
share