Cannot Write to sdcard in Android emulator(无法在 Android 模拟器中写入 SD 卡)

本文介绍了无法在 Android 模拟器中写入 SD 卡的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 AndroidManifest.xml 中添加了这一行:

I have added this line in the AndroidManifest.xml:

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

但是,当我运行代码写入 sdcard 时,我收到此错误:

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?

我正在使用添加了 SDCard 的 Android 模拟器.

I am using the Android Emulator with SDCard added.

EDIT-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

谢谢!

推荐答案

好的,我已经解决了这个问题.这是我在安装 sdcard 时遇到的问题,并且 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

注意:如果路径中有空格,请将 sdcard 图像文件移动到其他位置,然后使用 sdcard 运行模拟器命令,一切正常!

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!

这篇关于无法在 Android 模拟器中写入 SD 卡的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!