|
- FileOutputStream out = openFileOutput("myfile.test", MODE_WORLD_READABLE);
- File f = getFileStreamPath("myfile.test");
- writeDataToOutputStream(out);
- out.close();
- String filename = f.getAbsolutePath();
- Runtime r = Runtime.getRuntime();
- Process suProcess = r.exec("su");
- DataOutputStream dos = new DataOutputStream(suProcess.getOutputStream());
- dos.writeBytes("chown 0.0 " + filename + "\n");
- dos.flush();
- dos.writeBytes("chmod 644 " + filename + "\n");
- dos.flush();
- dos.writeBytes("mv " + filename + " /system/myfile.test\n");
- dos.flush();
複製代碼
The only thing left (not include din the code above) is to make /system writable. May be one additional command like mount -o rw,remount /system is sufficient - will test that.
在改變檔案權限時,請先r.exec("su");
就能正常執行下面語句
|
|