我正在尝试修改/etc/hosts/
文件,为此我在外部存储中创建了一个单独的文件,然后cp
将其保存到该位置。我收到这些错误消息:
01-14 18:51:51.069: E/HostsActivity(5356): rm failed for /etc/hosts, Read-only file system
01-14 18:51:51.079: E/HostsActivity(5356): failed on '/mnt/sdcard/hosts' - Cross-device link
我该怎么办?
我正在使用RootTools。
我的代码:
try {
String fn = write_file("hosts", hostsData);
RootTools.getShell(true).add(new Command(0, "rm /etc/hosts", "mv " + fn + " /etc/hosts")
{
@Override
public void output(int arg0, String arg1) {
// TODO Auto-generated method stub
Log.e("HostsActivity", arg1);
}
}).waitForFinish();
tv_status.setText("Done");
} catch (Exception ioe) {
Log.e("HostsActivity", ioe.toString());
tv_status.setText(ioe.toString());
}
我在活动开始时要求获得 root 权限onCreate
if (!RootTools.isAccessGiven()) {
TextView tv = new TextView(this);
tv.setText("Root access not given. Please ensure root access.");
setContentView(tv);
}
setContentView(R.layout.activity_hosts);