views:

650

answers:

1

hi.

In my application I want to create a directory xyz in sdcard at the runtime from the my Application.

But it doesn't work.

Here is my code..

public class process extends Activity {

/** Called when the activity is first created. */

@Override

public void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

    setContentView(R.layout.main);

       String[] str ={"mkdir","/sdcard/xyz"};

              try { 

        Process ps = Runtime.getRuntime().exec(str);
        try {
   ps.waitFor();
  } catch (InterruptedException e) {
   // TODO Auto-generated catch block
   e.printStackTrace();
  } 
        }

       catch (IOException e) {
        Toast.makeText(this, ""+e, Toast.LENGTH_LONG).show();
       }

}

}

A: 

I've no idea if you can exec() scripts in Android, I strongly suspect you can't.

You don't need to to make a directory anyway. Do this:

new File("/sdcard/xyz").mkdirs();

Jim Blackler