android 操作文件夹如果用java的io来操作速度非常慢,为了解决这个问题,得出如下方式,速度大大提升,分享给大家。代码如下:
public static void main(String [] args){
String fromPath = "mnt/sdCard/xuanqu";
String toPath = "mnt/sdCard/Android/data/com.test.cn/xuanqu";
File f = new File(toPath);
String command = "";
if(f.exists()) {
} else {
command = "mv " + fromPath + " " + toPath;
execCommand(command);
}
public boolean execCommand(String command){
Process process = null;
try{
process = Runtime.getRuntime().exec(command);
process.waitFor();
} catch (Exception e) {
return false;
}
return true;
}