超级用户和移动文件 [英] Superuser and moving files

查看:178
本文介绍了超级用户和移动文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从我的应用程序私有目录移到一个XML文件到另一个应用的私密目录。它要求我为超级用户正确的,我给他的权利,但他不移动文件。

I'm trying to move a XML file from my apps private directory to another apps private dir. It asks me for superuser properly, I grant him the rights but he doesn't move the file.

final Runtime runtime = Runtime.getRuntime();
            try {
                runtime.exec("su");
                runtime.exec("mv " + Environment.getDataDirectory().toString() + filename + " " + path);
            } catch (Exception e) {
                e.printStackTrace();
            }

为什么呢?文件名是FlappyBird.xml的方式,和路径是/data/data/com.dotgears.flappybird/shared_$p$pfs

Why? filename is "FlappyBird.xml" by the way, and path is "/data/data/com.dotgears.flappybird/shared_prefs"

另外,我想它是这样的:

Also, I tried it like this:

runtime.exec("mv /data/data/de.aciid.nullgc/files/FlappyBird2.xml /data/data/com.dotgears.flappybird/shared_prefs/");

也不起作用。

推荐答案

您正在执行两个独立的命令:

You're executing two independent commands:


  • 启动一个root shell(你后来无视)

  • MV 跑如你,这被认为失败

  • su starting a root shell (which you subsequently ignore)
  • mv ran as you, which is deemed to fail

您需要的是像

sudo mv src dst

作为根工作时要小心。

Be careful when working as root.

这篇关于超级用户和移动文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆