我想在 sdcard 中创建文件夹。我在 android 终端中使用以下命令
cd sdcard mkdir 音乐
mkdir 音乐失败,权限被拒绝。
试试下面的代码。它工作正常。
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
尝试以下链接在 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
谢谢..!
确保您已将 SDCard 支持添加到您的 AVD。
去eclipse - windows - avd manager - select avd and edit - hardware - new - SDCard Support
然后尝试命令。
创建目录时,最好提供完整路径而不是使用cd
用于Environment.getExternalStorageDirectory()
获取存储根目录。
使用以下命令创建目录:
String filepath=Environment.getExternalStorageDirectory()+"/Music"
File fc=new File(filepath)
if(!fc.exists())
fc.mkdir();