2015年4月1日 星期三

[Android] How to copy the files to /system or /data folder

For both folders"/system" and "/data",they are read-only modes by default.
If you need to copy files into them, you need some specific commands as shown below:

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();

The example shown above is to copy the file "/myTest/test.dat" in SD card to "/system" folder.

沒有留言:

張貼留言