且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

保存图片到SD卡的Andr​​oid目录问题

更新时间:2022-02-15 01:37:16

您目录到/ mnt / SD卡/ MVC / MVC可能不存在。那么改变你的路径存储在 Environment.getExternalStorageDirectory()路径中的图像,然后从那里工作?

Your directory "/mnt/sdcard/mvc/mvc" may not exist. What about changing your path to store the image in the Environment.getExternalStorageDirectory() path and then working from there?

此外,罗伯特指出,要确保你有write允许在清单中的外部存储。

Also, as Robert pointed out, make sure you have write permission to external storage in your manifest.

修改 - 创建目录:

String root = Environment.getExternalStorageDirectory().toString();
new File(root + "/mvc/mvc").mkdirs();

然后就可以将文件保存到根+/mvc/mvc/foo.png