不能写在Android模拟器到SD卡模拟器、写在、Android、SD

2023-09-13 23:52:26 作者:大爷范

我已经加入这一行在AndroidManifest.xml:

I have added this line in the AndroidManifest.xml:

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

然而,当我运行code写入SD卡,我得到这个错误:

However, when I run code to write to the sdcard , I get this Error:

02-19 13:24:46.760: E/CameraTest(598): /mnt/sdcard/image.jpg: open failed: EACCES (Permission denied)

我该如何解决这个问题?

How do I solve this problem?

编辑:我现在用的是Android模拟器使用SD卡添加

I am using the Android Emulator with SDCard added.

修改-2:我知道是什么问题,现在我已经调用的函数 Environment.getExternalStorageState()和我中删除。任何人知道如何解决这一问题,使国家 MEDIA_MOUNTED

EDIT-2: I know what the problem is now: I have called the function Environment.getExternalStorageState() and I get "removed". Anyone knows how to fix this and make the state MEDIA_MOUNTED

感谢您!

推荐答案

行,所以我已经解决了这一点。这是我面临的安装SD卡一个问题,Android的不允许在路径中有空格!

Ok So I have solved this. It was a problem I faced with mounting the sdcard and that android doesn't allow spaces in the path!

下面是一个很好的程序遵循(如果还使用了Eclipse):http://www.brighthub.com/mobile/google-android/articles/33240.aspx

Here is a good procedure to follow (if eclipse is also used) : http://www.brighthub.com/mobile/google-android/articles/33240.aspx

请注意:如果路径中有空格,将SD卡图像文件到别的地方,然后用SD卡运行仿真器的命令,一切都应该正常工作

NOTE: in case the path has a space in it, move the sdcard image file to somewhere else and then run the emulator command with the sdcard and everything should work fine!