我想在我的应用程序中读取图像并将其写入外部存储。根据我的阅读,以下是获取目录句柄的正确方法。
File externalStorageDir = Environment.getExternalStorageDirectory();
File picturesDir = new File(externalStorageDir, "Pictures");
然而 ...
picturesDir.exists(); // == null
picturesDir.mkdir(); // == false
是因为我用的是模拟器吗?
您可能需要确保启用了外部存储:
In Eclipse, go to Window > Android SDK and AVD Manager. Select the appropriate AVD and then click Edit.
确保您启用了 SD 卡支持。如果不这样做,请单击“新建”按钮并选择“SD 卡支持”选项。
编辑:还需要添加
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
到清单。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)