简体   繁体   English

chmod文件夹无法写入

[英]Can't chmod folder to write

In my apps (rooted devide), I want to chmod some files, folders to read and write. 在我的应用程序(rooted devide)中,我想对文件和文件夹进行chmod读写。 My code's here: 我的代码在这里:

String path = "/mnt/sdcard/.android_secure";
String[] chmod = { "su", "-c","chmod 777 "+path };
try {
    Runtime.getRuntime().exec(chmod);
} catch (IOException e) {
    e.printStackTrace();
}

File f = new File("/mnt/sdcard/.android_secure");
f.canRead();

But the file still unreadable! 但是文件仍然不可读!

I suggest you to read the output of the command to check the error reported by the command and then take the required corrective action. 建议您阅读命令的输出以检查命令报告的错误,然后采取所需的纠正措施。

Process process = Runtime.getRuntime().exec(chmod); 
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(process.getInputStream()));

String line;
while ((line = bufferedReader.readLine()) != null){

    Log.d("myTAG", line);
}

good luck 祝好运

Usually sdcard is formated in fat filesystem. 通常,sdcard是在胖文件系统中格式化的。 And this type of filesystem does not support unix style of file permissions. 并且这种类型的文件系统不支持Unix风格的文件权限。 Can you use the same code for checking if you can change permissions for folders on device? 您可以使用相同的代码来检查是否可以更改设备上文件夹的权限吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM