如果你在程式中想要將檔案複製過去,
需要先做一些處理,
程式範例如下:
Process process = Runtime.getRuntime().exec("su"); DataOutputStream output = new DataOutputStream(process.getOutputStream()); output.writeBytes("mount -o remount,rw -t yaffs2 /dev/block/mtdblock3 /system\n"); String sCatCommand = "cat "+Environment.getExternalStorageDirectory()+"/myTest/test.dat"+ "> /system/"+"test.dat"+"\n"; output.writeBytes(sCatCommand); output.writeBytes("mount -o remount,ro -t yaffs2 /dev/block/mtdblock3 /system\n"); output.writeBytes("exit\n"); output.flush(); process.waitFor();上面的範例,是將SD卡裡的"/myTest/test.dat"拷貝到"/system"
沒有留言:
張貼留言