0

我,我正在尝试构建需要另一个 APP 数据的 APP。

为此,我首先确保设备具有 root 访问权限,然后获得超级用户访问权限,最后我尝试从日期文件夹中读取一些文件,但 canRead() 函数返回 false。

代码 :

    if (IsRoot){ //check device root
        Process root = Runtime.getRuntime().exec("su");//SuperUser Permission
        if(appInstalledOrNot("com.app.name")) {//check application installed
        File cacheFile = new File(Environment.getDataDirectory().getAbsolutePath() + "/data/com.name.app/files/", "SOME_FILE"); //Get file
            if(cacheFile.exists()){
                Toast.makeText(this, "" + cacheFile.canRead(), Toast.LENGTH_SHORT).show(); //Toaste result (false return)
            }
        }

    }
4

1 回答 1

0

首先运行 chmod 命令以获得对特定路径的读写访问权限,例如某个路径“/data/com.name.app/files/”

使用这些命令

Process process = null; try { process = Runtime.getRuntime().exec(new String[] {"su" "mount -o rw,remount /system", "chmod -R 777 /data/com.name.app/files/", "mount -o ro,remount /system" }); process.waitFor(); } catch (Exception e) {}

而已

于 2016-04-21T08:13:51.710 回答