0
我也問過這個問題,因爲我需要有我的應用程序將創建一個使用超級用戶在/data
分區命令(我不典型目錄/data/data
如果創建文件的文件的寫權限沒有幾個),但我當前的代碼還沒有給出期望的結果:
public boolean creaArchivo2(String path, InputStream is)
throws IOException {
final int CHUNK_SIZE = 1024 * 4;
Process proc = Runtime.getRuntime().exec("su -c mount -o remount,rw "+path);
Process proc1 = Runtime.getRuntime().exec("su -c mount -o rw,remount -t yaffs2 /dev/block/mtdblock3 "+path);
OutputStream os = new FileOutputStream(new File(path));
byte[] chunk = new byte[CHUNK_SIZE];
int bytesLeidos = 0;
while ((bytesLeidos = is.read(chunk)) > 0) {
os.write(chunk, 0, bytesLeidos);
}
os.close();
return true;
}
解釋我的代碼:我的代碼你要做的就是嘗試設置讀取和對在分區中的文件的寫權限/數據然後複製d ata以傳統的方式與java,如果不是在命令中顯然發生的錯誤可以很容易地複製,但它不起作用。
如果他們意識到我的代碼在哪裏失敗或知道另一種方法來實現我的目標。請告訴我。謝謝