应该是权限的问题,你是ROOT了吧?
这样试试啊,看能不能在/system/etc 下面新建一个文件?
另外,问一下,你在运行这个程序时,“授权管理”有没有弹出窗口问你是否允许啊?
这样试试啊,看能不能在/system/etc 下面新建一个文件?
另外,问一下,你在运行这个程序时,“授权管理”有没有弹出窗口问你是否允许啊?
解决方案 »
- 如何控制TranslateAnimation 动画的滑动方向
- android模拟器启动停留于一画面 Waiting for HOME ('android.process.acore') to be launched...
- 高手来看看,给高分
- htc 2.1 google map 黑屏 问题
- source not found?
- SurfaceView做游戏,如何画面暂停?
- 求助!!!!!query的排序问题,读取联系人
- 2.3的AlarmClock
- 再问一个ArrayAdapter的问题~我不理解
- 手机休眠后感应器不工作问题
- 在线等,求教一个关于Animation 或者说是ViewFlipper的问题!
- adb push 的问题
已经弹出咯,也允许咯丫 ,能读,就是不打不开 FileOutputStream 流。
再试一下,用R.Explorer,直接编辑这个hosts,能保存吗?看看保存后是不是真的变了,,,因为我改试了,用R.Explorer编辑后保存,没变化,怪了,莫非我的ROOT失效了。
创建文件的上一层目录是 etc 目录权限 的权限是 dr-
请问权限怎么改? 执行Runtime.getRuntime().exec("su");行吗、?
谢谢了 先 不过,这样写,貌似还是不太行丫 还是抛出 java.io.FileNotFoundException: /system/etc/hosts 这样的异常哦
rootfs 指文件系统格式,每个硬件厂商的可能不一样。
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) {
Log.d("*** DEBUG ***", "Unexpected error - Here is what I know: "+e.getMessage());
return false;
}
finally {
try {
if (os != null) {
os.close();
}
process.destroy();
}
catch (Exception e) {
// nothing
}
}
return true;
} 麻烦你看下 上面的终端修改权限的代码 不合适吗 谢谢。、。
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) {
Log.d("*** DEBUG ***", "Unexpected error - Here is what I know: "+e.getMessage());
return false;
}
finally {
try {
if (os != null) {
os.close();
}
process.destroy();
}
catch (Exception e) {
// nothing
}
}
return true;
} 麻烦你看下 上面的终端修改权限的代码 不合适吗 谢谢。、。
貌似真是这样,不支持修改/system
如果不支持修改的话,呐 为什么 我new FileOutputStream(filePath)的是时候,hosts文件却被清空了呢, 这个hosts文件时放在/system/下的,而且这个文件本来是有内容的哦