我试图在etc文件夹中复制一个文件,因为我在一个按钮中使用了下一个代码:
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());
}
}
});问题是它没有复制任何东西。有什么问题吗?
谢谢。
发布于 2013-09-12 22:53:15
好的,接下来是最好的解决方案:
int date = (int) System.currentTimeMillis();
String source = "/system/etc/gps.conf";
String destination = "/system/etc/gps" + date + ".conf";
if(RootTools.remount("/system/etc/", "rw")){
RootTools.copyFile(source, destination, true, true);
}问题是前面我提到了/etc,但是这个位置是一个符号链接,真正的路径是/system/等等。很明显,我们不能改变符号链接的挂载类型,所以,我刚刚发布的前面的代码是很好的答案。
谢谢。
https://stackoverflow.com/questions/18747414
复制相似问题