在 SD 卡上创建新文件:权限被拒绝。我已经尝试了所有解决方案?
我确信我已经在manifest.xml中添加了WRITE_EXTERNAL_STORAGE权限,并且我还使用Environment.getExternalStorageState()检查了SD卡的状态,确保该值是Environment.MEDIA_MOUNTED,而不是Environment.MEDIA_SHARED或其他任何值。即使通过了这些检查,当我尝试创建新文件时仍然出现权限被拒绝错误!
到目前为止,此错误仅发生在 Nexus One 上。由于我自己没有Nexus One,无法直接调试。有人可以帮助我吗?
I am sure that I have added permission WRITE_EXTERNAL_STORAGE in manifest.xml, and I have also checked the state of SD card using Environment.getExternalStorageState(), makeing sure the value is Environment.MEDIA_MOUNTED, not Environment.MEDIA_SHARED or anything else. Even with these checks passed, there still is a permission denied error when I try to create new files!
This error only occurs on Nexus One so far. For I myself do not have a Nexus One, I cannot debug it directly. Could anybody help me?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我认为你应该尝试这个。不确定它是否能解决您的问题:
示例:
I think you should try this. Not sure if it will solve your problem:
example:
就我而言,Environment.MEDIA_MOUNTED 返回 false 并引发 IOException(权限被拒绝),因为我忘记将 SD 卡添加到我的 Android 虚拟设备。
As far as I was concerned, Environment.MEDIA_MOUNTED returned false and an IOException (Permission denied) was raised because I forgot to add a SD card to my Android Virtual Device.