I'm trying to make a copy of a file in the etc folder, for that I use the next code in a button:
changeNTP.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
File exists = new File("/etc/gps.conf");
if (exists.exists()) {
// We make a backup first
CommandCapture command = new CommandCapture(0, "cp -f /etc/gps.conf /etc/gps" + System.currentTimeMillis() + ".conf");
try {
RootTools.getShell(true).add(command);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (TimeoutException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (RootDeniedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
// Last time that file was modified
//Date filedate = new Date(exists.lastModified());
}
}
});
Well, the problem is that it doesn't copy anything. What could be the problem?
Thanks.
Ok, the next is best solution:
The problem is that previously I pointed to /etc, but this location is a symlink, the real path is /system/etc. Obviously we can't change mount type of a symlink, so, the previous code that I just have posted, is the good answer.
Thanks.