1. 程式人生 > >Android 掛載儲存只讀模式改成讀寫模式

Android 掛載儲存只讀模式改成讀寫模式

以 可讀寫的方式載入/data分割槽
mount -o rw,remount /data

應用上使用

public static void setPerssion(){
    exusecmd("mount -o rw,remount /data");
    exusecmd("chmod 777 /data/data/shensi");
}
public static boolean exusecmd(String command) {
    Process process = null;
    DataOutputStream os = null;
    try {
        process = Runtime.getRuntime().exec("su"
); os = new DataOutputStream(process.getOutputStream()); os.writeBytes(command + "\n"); os.writeBytes("exit\n"); os.flush(); process.waitFor(); } catch (Exception e) { return false; } finally { try { if (os != null) { os.close(); } if
(process != null) { process.destroy(); } } catch (Exception e) { e.printStackTrace(); } } return true; }