代码这个
OutputStream imageFileOS; int imageNum = 0; Intent imageIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE); File imagesFolder = new File(Environment.getExternalStoragePublicDirectory( Environment.DIRECTORY_PICTURES),"Punch"); if(!imagesFolder.exists()){ imagesFolder.mkdirs(); // <---- } String fileName = "image_" + String.valueOf(imageNum) + ".jpg"; File output = new File(imagesFolder,fileName); while (output.exists()){ imageNum++; fileName = "image_" + String.valueOf(imageNum) + ".jpg"; output = new File(imagesFolder,fileName); } Uri uriSavedImage = Uri.fromFile(output); imageIntent.putExtra(MediaStore.EXTRA_OUTPUT,uriSavedImage);
当我运行代码并检查时,它有“内存/图片/打孔/图像_0.jpg”中的文件
但在SD卡中看不到(SD卡=外部存储卡16 GB)
请帮我 ..
解决方法
它获取由设备制造商指定的主存储目录.这通常是“sdcard”.注释中指定的“External_sd”实际上是辅助存储目录,不会在给定方法中返回.
这仍然不是受保护的内部存储,并且可以在连接时由Pcs安装和访问.
来自android文档:
Note: don’t be confused by the word “external” here. This directory can better be thought as media/shared storage. It is a filesystem that can hold a relatively large amount of data and that is shared across all applications (does not enforce permissions). Traditionally this is an SD card,but it may also be implemented as built-in storage in a device that is distinct from the protected internal storage and can be mounted as a filesystem on a computer.
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。