无法访问SD卡
我正在尝试将文件读/写到 SD 卡。我已经尝试在我的真实手机和 Eclipse 模拟器上执行此操作。在这两种设备上,对 /mnt/sdcard/ 或 /sdcard 的权限仅为“d--------”,我想这意味着我无法读取或写入。
我无法从 eclipse 中的“文件视图”打开该文件夹,而且当我也尝试“adb pull /mnt/sdcard/test.txt test.txt”时,我得到远程对象不存在。
Android应用程序确实具有“WRITE_EXTERNAL_STORAGE”权限。
例如,这是我在运行应用程序时所做的事情;
try {
File root = Environment.getExternalStorageDirectory();
Log.e(TAG,root.getAbsolutePath());
File gpxfile = new File(root, "test.txt");
FileWriter gpxwriter = new FileWriter(gpxfile);
BufferedWriter out = new BufferedWriter(gpxwriter);
out.write("Hello world");
out.close();
} catch (IOException e) {
Log.e(TAG, "Could not write file " + e.getMessage());
}
我没有例外。 有什么想法吗?这个问题快要死我了!
I'm trying to read/write files to the sdcard. I've tried doing this both on my real phone and on an emulator in eclipse. On both devices the permission to the /mnt/sdcard/ or /sdcard is only "d--------", which I guess means I can't read or write.
I cant open the folder from the "File view" in eclipse, and also when I also try the "adb pull /mnt/sdcard/test.txt test.txt" I get the remote object does not exist.
The android app does have the permission to "WRITE_EXTERNAL_STORAGE".
Here's for example what I do when running the app;
try {
File root = Environment.getExternalStorageDirectory();
Log.e(TAG,root.getAbsolutePath());
File gpxfile = new File(root, "test.txt");
FileWriter gpxwriter = new FileWriter(gpxfile);
BufferedWriter out = new BufferedWriter(gpxwriter);
out.write("Hello world");
out.close();
} catch (IOException e) {
Log.e(TAG, "Could not write file " + e.getMessage());
}
I do not get an exception.
Any ideas? This problem is killing me!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是一个示例,您可以从特定的 url 显示 sdcard 中的图像,因此您需要权限,例如 ...
权限 ::
Java 文件 ::
有时还面临设备中的问题,我们的互联网连接丢失或我们无法找到SD卡
This is example where you can show image in sdcard from perticular url so you need permission like ...
permission ::
Java file ::
And some time also face problem in device that our Internet connection missed or we cant able to find sdcard