-1
請問有人可以幫我嗎?我有這樣的代碼:如何將字符串設置爲共享首選項?
Process a;
try {
a = Runtime.getRuntime().exec("su");
DataOutputStream swp = new DataOutputStream(a.getOutputStream());
swp.writeBytes("cat /proc/sys/vm/blabla\n");
swp.writeBytes("exit\n");
swp.flush();
try {
a.waitFor();
if (a.exitValue() != 255) {
// TODO Code to run on success
toastMessage("root");
}
else {
// TODO Code to run on unsuccessful
toastMessage("not root");
}
} catch (InterruptedException e) {
// TODO Code to run in interrupted exception
toastMessage("not root");
}
} catch (IOException e) {
// TODO Code to run in input/output exception
toastMessage("not root");
}
此代碼swp.writeBytes("cat /proc/sys/vm/blabla\n");
複製文本(字符串)從所謂的「布拉布拉」系統文件。然後我需要把這個文本(字符串)放到我的SharedPreferences中。我怎樣才能實現它?
我知道如何將String放入SharedPreferences,但在這種情況下,它更復雜。問題在於貓命令。你能舉一些例子嗎? – Adam
好吧,我明白了,非常感謝。 – Adam