I want to copy all the contents of a folder to another folder on SDCard. I want to do it at OS level. I've tried using the following command : cp -a /source/. /dest/, this doesn't work, It says Permission Denied as my device is not rooted. However an interesting thing is that it allows me to execute rm - r source
String deleteCmd = "rm -r " + sourcePath;
Runtime delete_runtime = Runtime.getRuntime();
try {
delete_runtime.exec(deleteCmd);
} catch (IOException e) {
Log.e("TAG", Log.getStackTraceString(e));
}
Kindly tell me if there exists a way through which i can achieve this at OS level else my last resort will be this LINK. Thanks in advance.
After researching more i found the perfect solution that suits my requirement. The file copy is TREMENDOUSLY FAST.
The mv command doest the magic for me, it moves all the files inside the source folder to the destination folder and after copying it deletes the source folder.
String copyCmd = "mv " + sourcePath + " " + destinationPath;
Runtime copy_runtime = Runtime.getRuntime();
try {
copy_runtime.exec(copyCmd);
} catch (IOException e) {
Log.d("TAG", Log.getStackTraceString(e));
}