8

我想在 sdcard 中创建文件夹。我在 android 终端中使用以下命令

cd sdcard mkdir 音乐

mkdir 音乐失败,权限被拒绝。

4

4 回答 4

13

试试下面的代码。它工作正常。

you need to run emulator before run the below commands.
use the adb shell command from the android tools folder.
eg (this was on windows):
cd android-sdk-windows\tools
adb shell
cd /sdcard/
mkdir myfolder

在此处输入图像描述 在此处输入图像描述

于 2012-04-27T05:22:08.693 回答
2

尝试以下链接在 sdcard 中创建文件夹

在链接下方创建文件夹终端窗口:

http://android-er.blogspot.in/2010/10/how-to-create-sub-folder-in-sd-card-of.html

以编程方式创建文件夹:

http://android-er.blogspot.in/2010/10/how-to-create-sub-folder-in-sd-card.html

谢谢..!

于 2012-04-27T05:23:13.657 回答
2

确保您已将 SDCard 支持添加到您的 AVD。

eclipse - windows - avd manager - select avd and edit - hardware - new - SDCard Support

然后尝试命令。

于 2012-04-27T05:30:07.113 回答
2

创建目录时,最好提供完整路径而不是使用cd

用于Environment.getExternalStorageDirectory()获取存储根目录。

使用以下命令创建目录:

String filepath=Environment.getExternalStorageDirectory()+"/Music"
File fc=new File(filepath)
if(!fc.exists())       
        fc.mkdir();
于 2012-04-27T05:38:03.230 回答