This is a topic that I couldn’t help but notice is MIA from many Android tutorials and books, even though its a relatively simple process. If you are familiar with creating and working with directories and files in Java, there’s nothing new here, but what threw me off initially was where to actually put the darn directory.

public class DirectoryTest extends Activity {

     private static final String TAG = "DirTest Output:";

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        File sddir = new File("/sdcard/testDirectory");

        if (sddir.mkdirs()) {
             Toast toast = Toast.makeText(this,
             "Directory successfully created!",
					Toast.LENGTH_SHORT);
	     toast.setGravity(Gravity.CENTER, 0, 0);
	     toast.show();
        }else{
             Log.e(TAG, "Create dir in sdcard failed");
             Toast toast = Toast.makeText(this,
             "Directory creation failed!",
 					Toast.LENGTH_SHORT);
 	     toast.setGravity(Gravity.CENTER, 0, 0);
 	     toast.show();
        }
    }
}

Like I said, pretty simple. We create a new file object with the path to the SD card, which happens to just be /sdcard, and then we call the mkdirs() method, which will create all the directories along the chain we specified in our File object. Nice and easy.