我用system("system/test"),执行一个脚本,但好像没有执行,在命令行下执行是好的,
请问为什么,android是否封装了其他的API?谢谢

解决方案 »

  1.   

    String command = "rm /data/***";  // the command that will be execute    
            Runtime runtime = Runtime.getRuntime();      
            Process proc = null;
                
            try {
                proc = runtime.exec(command);
            } catch (IOException e1) {
                e1.printStackTrace();
            }
            
            // put a BufferedReader on the ps output     
            InputStream inputstream = proc.getInputStream();
            InputStreamReader inputstreamreader = new InputStreamReader(inputstream);    
            BufferedReader bufferedreader = new BufferedReader(inputstreamreader);    
            
            // read the ps output and show it to screen.
            ...
            ...        // judge the return value         
            try {    
                if (proc.waitFor() != 0) {    
                    System.err.println("exit value = " + proc.exitValue());    
                }     
            }    
            catch (InterruptedException e) {
                System.err.println(e);
            }