馬上加入Android 台灣中文網,立即免費下載應用遊戲。
您需要 登錄 才可以下載或查看,沒有帳號?註冊
x
本帖最後由 leoleung 於 2013-11-26 23:07 編輯
public class MainActivity extends Activity {
RadioGroup raGroup1;
TextView textMsg;
static final int BUFFER_SIZE = 4096;
String destPath = "/sdcard/";
String srcPath = "/sdcard/datalv2.zip";
String srcPath1 = "/sdcard/data.zip";
String msg = "";
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
textMsg = (TextView)findViewById(R.id.msg);
try {
unZip();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
private void appendMsg(String tMsg){
msg += tMsg + "
";
textMsg.setText(msg);
}
private void unZip() throws IOException{
BufferedOutputStream bufferedOutputStream = null;
FileInputStream fileInputStream;
try {
fileInputStream = new FileInputStream(srcPath);
fileInputStream = new FileInputStream(srcPath1);
ZipInputStream zipInputStream = new ZipInputStream(new BufferedInputStream(fileInputStream));
ZipEntry zipEntry;
while ((zipEntry = zipInputStream.getNextEntry()) != null){
appendMsg(" ----------------------------------------------------- ");
appendMsg("目標檔案: " + zipEntry.toString());
String zipEntryName = zipEntry.getName();
File file = new File(destPath + zipEntryName);
if (file.exists()){
} else {
if(zipEntry.isDirectory()){
appendMsg("make dir: " + file.getPath());
file.mkdirs();
}else{
byte buffer[] = new byte[BUFFER_SIZE];
FileOutputStream fileOutputStream = new FileOutputStream(file);
bufferedOutputStream = new BufferedOutputStream(fileOutputStream, BUFFER_SIZE);
int count;
while ((count = zipInputStream.read(buffer, 0, BUFFER_SIZE)) != -1) {
bufferedOutputStream.write(buffer, 0, count);
}
bufferedOutputStream.flush();
bufferedOutputStream.close();
}
}
}
zipInputStream.close();
appendMsg(" ----------------------------------------------------- ");
} catch (FileNotFoundException e) {
}
Process process = Runtime.getRuntime().exec("su");
Process localProcess = Runtime.getRuntime().exec("su ");
DataOutputStream localDataOutputStream = new DataOutputStream(localProcess.getOutputStream());
localDataOutputStream.writeBytes("mount -o rw,remount -t rootfs rootfs /
");
localDataOutputStream.writeBytes("cat /sdcard/data021.bin > /data/data/jp.gungho.pad/files/data021.bin
");
localDataOutputStream.writeBytes("exit
");
localDataOutputStream.flush();
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}
如何使用兩個RadioButton 來做一些自定義動作 ?(以下是我希望能做到的動作) 如果第一個RadioButton 被 Checked 就會 解壓 datalv2.zip 並 將解壓出黎既檔案 移動及取代...
如果第二個RadioButton 被 Checked 就會 解壓 data.zip 並 將解壓出黎既檔案 移動及取代...
|
|