【问题标题】:Access data folder in root device访问根设备中的数据文件夹
【发布时间】:2015-08-17 13:19:33
【问题描述】:

我正在尝试构建需要另一个应用程序数据的应用程序。

为此,我首先确保设备具有 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)
            }
        }

    }

【问题讨论】:

    标签: android permissions root superuser


    【解决方案1】:

    首先运行 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) {}

    就是这样

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-05-17
      • 2012-09-28
      • 1970-01-01
      • 2012-05-31
      • 1970-01-01
      • 1970-01-01
      • 2016-08-24
      • 2013-02-12
      相关资源
      最近更新 更多