1.首先要注意权限问题
<uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS"></uses-permission>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"></uses-permission>
2.file.createNewFile() 方法出现的问题
会出现No such file ..的问题
需要注意的是:要先对设计的文件路径创建文件夹 , 然后在对文件进行创建
String local_file = Environment.getExternalStorageDirectory().getAbsolutePath()+"/down/";
File f = new File(local_file);
if(!f.exists()){
f.mkdirs();
}
String local_file = f.getAbsolutePath()+"/"+filename;
File f = new File(local_file);
try {
if(!file.createNewFile()) {
System.out.println("File already exists");
}
} catch (IOException ex) {
System.out.println(ex);
}