【问题标题】:Change the SharedPreferences of another application using super user使用超级用户更改另一个应用程序的 SharedPreferences
【发布时间】:2012-10-19 17:28:48
【问题描述】:

我正在尝试使用超级用户来修改另一个应用程序的 SharedPreferences。

这是我的做法:

        Process suProcess = Runtime.getRuntime().exec("su");

        DataOutputStream os = new DataOutputStream(suProcess.getOutputStream());

        os.writeBytes("echo \"<?xml version='1.0' encoding='utf-8' standalone='yes' ?><map><string name='commentAuthorName'>toto</string></map>\" > /data/data/com.adobe.reader/shared_prefs/com.adobe.reader.preferences.xml' \n");

        os.writeBytes("exit\n");
        os.flush();
        os.close();

        suProcess.waitFor();

但发生的情况是我的应用程序冻结了。

我做错了什么?

另外,是否有更好的方法来修改我不拥有的另一个应用程序的 SharedPreferences ?

提前致谢。

扎布

【问题讨论】:

    标签: android sharedpreferences su


    【解决方案1】:

    尝试在preferences.xml 之后删除行尾的单引号。

    【讨论】:

    • 我刚刚做了,但它仍然冻结: Process suProcess = Runtime.getRuntime().exec("su");知道为什么吗?我在 Android 3.1 的 root 版本上运行,其他 root 应用程序在此设备上运行良好,我的超级用户版本是:V2.3.6.1
    • 它可能正在等待您输入密码。有一些安全的方法可以做到这一点,通过 shell 调用调用 su 不是其中之一。
    【解决方案2】:

    好的,我现在知道为什么我的应用程序冻结了(准确地说,它冻结在:Process suProcess = Runtime.getRuntime().exec("su");)。

    我正在开发的应用程序是 AIR for Android 的原生扩展。我正在从 Flash builder 启动我的应用程序,显然,这会导致冻结...

    从设备正常启动应用程序时,一切正常。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2022-01-04
      • 1970-01-01
      • 1970-01-01
      • 2020-05-22
      • 2012-04-20
      • 2010-10-09
      • 2014-03-31
      相关资源
      最近更新 更多