Files:
root@generic_x86:/storage # ls -la 1AF9-2810/
-rwxrwx--x root sdcard_rw 348218 2016-08-19 17:55 2012 (1).JPG
-rwxrwx--x root sdcard_rw 106512 2014-12-05 19:49 2012 (2).jpg
drwxrwx--x root sdcard_rw 2016-08-16 19:36 Android
drwxrwx--x root sdcard_rw 2016-08-16 19:36 LOST.DIR
Android API 23 Permissions granted:
ActivityCompat.checkSelfPermission(context, Manifest.permission.READ_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED
true
ActivityCompat.checkSelfPermission(context, Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED
true
Test new file 1: ko
new File("/storage/emulated/1AF9-2810/test1").createNewFile()
IOException - open failed: ENOENT (No such file or directory)
Test new file 2: ko
new FileOutputStream("/storage/emulated/1AF9-2810/test2", false)
FileNotFoundException - /storage/emulated/1AF9-2810/test2: open failed: ENOENT (No such file or directory)
Test existing file: ko
new FileOutputStream("/storage/emulated/1AF9-2810/2012 (1).JPG", false)
FileNotFoundException - /storage/emulated/1AF9-2810/2012 (1).JPG: open failed: ENOENT (No such file or directory)
Test /storage/emulated/0: ok
new FileOutputStream("/storage/emulated/0/test3.JPG", false)
FileOutputStream OK!!
The original Google Android Gallery has Write access to my images and can write into it. (See timestamp "2016-08-19 17:55 2012 (1).JPG")
Can someone explain what happens? Why can't I write into the sd card path /storage/emulated/1AF9-2810?
root@generic_x86:/storage # ls -la
drwxrwx--x root sdcard_rw 2016-08-19 17:55 1AF9-2810
drwx--x--x root sdcard_rw 2016-08-19 17:28 emulated
drwxr-xr-x root root 2016-08-19 17:28 self
df
root@generic_x86:/storage # df
Filesystem Size Used Free Blksize
/dev 249.6M 44.0K 249.6M 4096
/sys/fs/cgroup 249.6M 12.0K 249.6M 4096
/mnt 249.6M 0.0K 249.6M 4096
/system 1.2G 861.7M 378.2M 4096
/cache 61.0M 64.0K 60.9M 4096
/data 1.9G 205.6M 1.7G 4096
/storage 249.6M 0.0K 249.6M 4096
/mnt/runtime/default/emulated 1.9G 205.6M 1.7G 4096
/storage/emulated 1.9G 205.6M 1.7G 4096
/mnt/runtime/read/emulated 1.9G 205.6M 1.7G 4096
/mnt/runtime/write/emulated 1.9G 205.6M 1.7G 4096
/mnt/media_rw/1AF9-2810 1020.0M 474.0K 1019.5M 2048
/mnt/runtime/default/1AF9-2810 1020.0M 474.0K 1019.5M 2048
/storage/1AF9-2810 1020.0M 474.0K 1019.5M 2048
/mnt/runtime/read/1AF9-2810 1020.0M 474.0K 1019.5M 2048
/mnt/runtime/write/1AF9-2810 1020.0M 474.0K 1019.5M 2048
Edit: Interesting discussion: http://forum.xda-developers.com/showthread.php?t=2634840&page=2
But it does not work without root access. We need the WRITE_MEDIA_STORAGE permission which is only allowed for system processes.