2013-01-14 67 views
0

我试图修改/etc/hosts/文件,并为此我在外部存储中创建一个单独的文件,然后cp它到位。我收到这些错误消息:扎根android只读文件系统错误

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()); 
     } 

我在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); 
+0

请显示您使用的密码 – Simon

+0

@Simon:更新 – prongs

回答

0

您需要在默认情况下挂载/等要求root权限在活动的开始,它是只读文件系统。
比您需要检查/ etc/hosts上的权限,也许您需要使用chmod命令更正文件权限。

+0

您能更具体吗?也许显示命令? – prongs

+0

http://stackoverflow.com/questions/7794659/how-to-change-the-hosts-file-on-android – EvZ

+0

试过这个,但仍然有一个错误:'RootTools.getShell(true).add(new Command( 0,“mount -o rw,remount/system”,“cp”+ fn +“/ etc/hosts”)' – prongs

相关问题