在 Nexus S 的 SD 卡上保存时出现问题
我无法在 Nexus S 上保存文本文件。状态已安装,路径正常 (/sdcard/filename
),我的清单文件中有用于外部存储的权限。
该程序在这一行给出了 IOException
:
File file = new File(path, fileName + ".txt");
我不知道如何检测问题,特别是如果它在 Galaxy Mini 上运行良好的话。一段时间以来,我一直在努力在 Samsung Galaxy 上保存 txt 文件,但通过从定义最小 sdk 版本的清单文件中删除一行使其工作。事实上它不接受任何最小的 sdk 版本,所以我现在完全删除了它......
任何人都可以帮忙吗?
I cannot save a text file on a Nexus S. State is mounted, path is ok (/sdcard/filename
), there is a permission in my manifest file for extenal storage.
The program gives an IOException
on this line:
File file = new File(path, fileName + ".txt");
I have no idea how to detect the problem, especially if it works fine on a Galaxy Mini. I have been struggling saving a txt file on Samsung Galaxy for some time, but made it work by removing a line from the manifest file defining the min sdk version. It did not accept any min sdk version in fact, so I removed it altogether for now...
Can anyone help?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试一下
try it out
如文档中所述,您应该首先检查外部媒体已安装:
然后通过
Environment.getExternalStorageDirectory()
。如果您打算保存公开访问的文件(图片、视频、音乐等),请使用
环境。 getExternalStoragePublicDirectory(..)
带有适当的参数。As described in the docs, you should first check that external media is mounted:
and then use it via
Environment.getExternalStorageDirectory()
.If you plan to save publicly accessed files (pictures, videos, music, etc..) then use
Environment. getExternalStoragePublicDirectory(..)
with appropriate argument.