Android 掛載儲存只讀模式改成讀寫模式
阿新 • • 發佈:2019-01-10
以 可讀寫的方式載入/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;
}