我尝试更改应用程序中的文件权限。代码如下:
Runtime.getRuntime().exec("chmod 777 /sdcard/test.txt");
此代码在我的应用程序中不起作用,但没有错误日志。 我还检查了/system/bin 下的 shell 工具,发现 chmod 在/system/bin 下,但其他一些信息显示 chmod > 工具箱。我不清楚这一点。我的应用程序使用了 android:sharedUserId="android.uid.system"。 如何运行此代码或如何更改文件的权限?非常感谢。
最佳答案
Runtime rt = Runtime.getRuntime();
Process proc;
try {
proc = rt.exec(new String[] { "su", "-c", "chmod 777 " + Constants.filename });
proc.waitFor();
} catch (Exception e){ //DOSTUFFS }
这应该可以解决问题
关于android - 更改应用程序中的文件权限,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8412384/