0
我裏面的SD卡Android的子文件夾的SD卡
File f = new File(Environment.getExternalStorageDirectory() + "/res/");
f.mkdirs();
成功創建該文件夾創建一個名爲「資源」文件夾中。
但是,當我嘗試在文件夾內創建文件不起作用。
String string = "hello!";
File file = new File(Environment.getExternalStorageDirectory() + "/res/","test.txt");
FileOutputStream fos = new FileOutputStream(file);
fos.write(string.getBytes());
fos.close();
logcat的
java.io.FileNotFoundException: /mnt/sdcard/res/test.txt (Not a directory)
只需調用'file.createNewFile();'第一個 –