0
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文件具有所有 -rw 权限。我尝试了几种方法,但每次都不成功。

注意:我的手机已root。

4

1 回答 1

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的问题

于 2013-04-16T13:27:55.953 回答