String inputPath= mFilePathTextView.getText().toString();
System.out.println("paa"+inputPath);
File outputPath = new File(Environment.getExternalStorageDirectory().toString()+"/recycle/");
System.out.println("paaa"+outputPath);
// File (or directory) to be moved
//String outputPath="/mnt/sdcard/";
//File dir = new File(outputPath);
if (!outputPath.exists()) {
outputPath.mkdir();
}
in = new FileInputStream(inputPath);
out = new FileOutputStream(outputPath);
byte[] buf = new byte[1024];
int len;
while ((len = in.read(buf)) > 0) {
out.write(buf, 0, len);
}
in.close();
out.close();
// delete the original file
//new File(inputPath).delete();
我正在成功创建文件夹,但文件未在此文件夹上复制。我想移动任何类型的文件。
答案 0 :(得分:0)
这可能有助于你
if (android.os.Environment.getExternalStorageState().equals(android.os.Environment.MEDIA_MOUNTED))
File fDir = new File(android.os.Environment.getExternalStorageDirectory(),"recycle");
现在检查文件是否存在,同时确保在AndroidManifest.xml
文件