Cannot Write to sdcard in Android emulator(无法在 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 卡的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:无法在 Android 模拟器中写入 SD 卡
基础教程推荐
- 如何从 logcat 中删除旧数据? 2022-01-01
- NSString intValue 不能用于检索电话号码 2022-01-01
- 通过重定向链接在 Google Play 中打开应用 2022-01-01
- iOS4 创建后台定时器 2022-01-01
- iPhone - 获取给定地点/时区的当前日期和时间并将其与同一地点的另一个日期/时间进行比较的正确方法 2022-01-01
- Cocos2d iPhone 非矩形精灵触摸检测 2022-01-01
- libGDX 从精灵或纹理中获取像素颜色 2022-01-01
- Android:getLastKnownLocation(LocationManager.NETWORK_PROVIDER 2022-01-01
- navigator.geolocation.getCurrentPosition 在 Android 浏览器上 2022-01-01
- AdMob 广告未在模拟器中显示 2022-01-01
