0

I am creating an application that will access super user programmatically.Here i write some piece of code it will executes commands perfectly but my application was going to freezes and finally crashes after some time please help me with this. This is What i had did

public class MainActivity extends Activity {
    Button files;
    File path;
    String directory_name;
    EditText edit_text_files;
    FileOutputStream fos;
    String [] commands = new String[10];
    boolean su;

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

            Process process = Runtime.getRuntime().exec("su");
            DataOutputStream data_out = new DataOutputStream(process.getOutputStream());
            DataInputStream data_in = new DataInputStream(process.getInputStream());
            data_out.writeBytes("mkdir mnt/udisk/samplefolder"+"\n");
            data_out.flush();

            data_out.writeBytes("exit \n");
            data_out.flush();
            process.waitFor();

        }
        catch(Exception e)
        {
            Log.e("Commands Exception :", "executing commands exception");
        }
lakshman
  • 1
  • 2
  • You can't run those three steps in separate processes. And `cd` makes no sense as a separate process. It is a shell built-in. You specify the working directory when you start the process. And `mkdir` does not need a working directory if you specify a full path. – Thilo Sep 11 '15 at 05:39
  • dude i modified my question can you please help me @Thilo – lakshman Sep 11 '15 at 06:15

0 Answers0