3
我真的嘗試了一切:更改系統文件的權限
- NetHackFileHelpers
- How to get File Permission Mode programmatically in Java
- Change file permission in application
- Mount R/W system in android application to edit Read Only files
現在,假設我已經重新安裝的根目錄,因此RW
文件系統權限(Android版本2.3.7) :
Process process = Runtime.getRuntime().exec("su");
DataOutputStream os = new DataOutputStream(process.getOutputStream());
os.writeBytes("chmod -c 0777 /system/etc/customization/settings/com/android/browser/custom_settings.xml\n");
os.writeBytes("exit\n");
os.flush();
process.waitFor();
或:
Process process = Runtime.getRuntime().exec("su -c \"/system/etc/customization/settings/com/android/browser/custom_settings.xml\"");
或:
Class<?> fileUtils = Class.forName("android.os.FileUtils");
Method setPermissions =
fileUtils.getMethod("setPermissions", String.class, int.class, int.class, int.class);
int a = (Integer) setPermissions.invoke(null, "/system/etc/customization/settings/com/android/browser/custom_settings.xml", 0777, -1, -1);
的行爲是一樣的:沒有任何反應。而如果我從adb shell的chmod
工作正常。我如何在代碼中更改該文件的權限?
所以這是對我的作品的人。 – 2013-07-22 06:18:52
http://examples.javacodegeeks.com/core-java/io/file/set-file-permissions-in-java-example/ – vangorra 2014-09-04 21:08:26