[英]File not found inside "/storage/emulated/0/Pictures/"
I am accessing a file from " /storage/emulated/0/Pictures/1565704523555.jpg
".我正在访问来自“
/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.当我列出“
/storage/emulated/0/Pictures/
”中的所有文件时,我可以看到该目录中的文件。
Whenever I use " Environment.getExternalStorageDirectory().toString()+/Pictures
"每当我使用“
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.我正在模拟器上尝试这个。
Use Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES)
instead of Environment.getExternalStorageDirectory().toString()+/Pictures
.使用
Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES)
而不是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
如果您想使用您的私有应用程序图片目录,请使用
context.getExternalFilesDir(Environment.DIRECTORY_PICTURES)
,其中context
是 Android Context
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.