无法编辑“/ sys / devices / virtual / sound / timer / dev”文件

时间:2013-04-15 01:12:39

标签: android

public class MainActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }


    private static final String SYSFS = "/sys/devices/virtual/sound/timer/dev";
    public void Place1() throws IOException {
        // Open the sysfs file for writing and write "116:33/34" to it.  
        PrintWriter outStream = new PrintWriter(new FileWriter(SYSFS));
        outStream.write("116:34");
        outStream.close();
    } 

}

我是Java和Android开发的新手,所以我正在编写这个简单的代码来更改 dev 文件,但它似乎不起作用。 dev 文件具有所有-rw权限。我尝试过几种方式,但每次都不成功。

注意:我的手机已植根。

1 个答案:

答案 0 :(得分:0)

public class MainActivity extends Activity {

private static final String SYSFS = "/sys/devices/platform/omap3epfb.0/graphics/fb0/fmode"; 

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    try {
            File file = new File(SYSFS);
            FileWriter fw = new FileWriter(file.getAbsoluteFile());
            BufferedWriter bw = new BufferedWriter(fw);
            bw.write("1");
            bw.close();

        } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

}    

这很有效。 也许是 PrintWriter 问题