File folder = new File("/sdcard/"+ "testFolder");
if (!folder.exists())
{
folder.mkdirs();
Log.i("Sound folder", "Sound Folder created..");
}
else
{
Log.i("Sound folder", "Sound Folder already exists");
}
我在android manifest.xml中设置了权限,这里是:
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
但检查文件夹时我找不到!!我错过了什么
答案 0 :(得分:1)
File
不会创建该文件夹。结帐mkDirs()
folder.mkDirs();
http://developer.android.com/reference/java/io/File.html#mkdirs()
你不应该使用“/ sdcard”。相反,请使用Environment.getExternalStorageDirectory()
File folder = new File(Environment.getExternalStorageDirectory() + "testFolder");