如何在android2.2的mnt/sdcard中创建目录
我用安卓2.2在HTC上进行了尝试,但并没有创建目录和文件。如果我在三星S2和安卓4上尝试这个,那么它就可以工作了如何在android2.2的mnt/sdcard中创建目录,android,Android,我用安卓2.2在HTC上进行了尝试,但并没有创建目录和文件。如果我在三星S2和安卓4上尝试这个,那么它就可以工作了 为什么这在HTC和android 2.2上不起作用?您需要创建该文件 () 您是否在清单上添加了android.permission.WRITE_外部_存储? File dir = Environment.getExternalStorageDirectory(); if (dir.exists() && dir.isDirectory()) {
为什么这在HTC和android 2.2上不起作用?您需要创建该文件 ()
您是否在清单上添加了android.permission.WRITE_外部_存储?
File dir = Environment.getExternalStorageDirectory();
if (dir.exists() && dir.isDirectory()) {
String exStoragePath = Environment.getExternalStorageDirectory().getAbsolutePath();
File appPath = new File(exStoragePath + "/mbrc/");
appPath.mkdirs();
String tempFilename = "tmp.wav";
String tempDestFile = appPath.getAbsolutePath() + "/" + tempFilename;
return tempDestFile;
}
File dir = Environment.getExternalStorageDirectory();
if (dir.exists() && dir.isDirectory()) {
String exStoragePath = Environment.getExternalStorageDirectory().getAbsolutePath();
File appPath = new File(exStoragePath + "/mbrc/");
appPath.mkdirs();
String tempFilename = "tmp.wav";
String tempDestFile = appPath.getAbsolutePath() + "/" + tempFilename;
File newFile = new File(tempDestFile);
newFile.createNewFile();
return tempDestFile;
}