I'm trying to programmatically move files from the internal memory in Android to a existing directory in the SD card.
I tried two ways.
In the first one I used File.renameTo:
String destName = externalDirPath + File.separatorChar + destFileName;
File originFile = new File(cacheDirPath + File.separatorChar + originalfileName);
originFile.renameTo(new File(destName));
In the other I used Runtime.getRuntime():
Process p = Runtime.getRuntime().exec("/system/bin/sh -");
DataOutputStream os = new DataOutputStream(p.getOutputStream());
String command = "cp " + cacheDirPath + "/" + originalfileName+ " " + externalDirPath + "/" + destFileName+ "\n";
os.writeBytes(command);
With both of them it doesn't work..
Any suggestion?