Reputation: 23
I am accessing a file from
"/storage/emulated/0/Pictures/1565704523555.jpg
". When I check if the file exists it tells me that the file was not found.
I have given all run-time permissions.
When I list all files from "/storage/emulated/0/Pictures/
" I can see the file in that directory.
Whenever I use "Environment.getExternalStorageDirectory().toString()+/Pictures
"
I can access all the files from this folders and it shows that the file exists.
I am trying this on an emulator.
Upvotes: 2
Views: 5101
Reputation: 1382
Use Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES)
instead of Environment.getExternalStorageDirectory().toString()+/Pictures
.
And if you want to use your private application pictures directory use context.getExternalFilesDir(Environment.DIRECTORY_PICTURES)
, where context
is Android Context
Upvotes: 6