Take the 2-minute tour ×

Tonight I am currently having issues doing something that I thought would be simple... making a folder in /mnt/sdcard.

I have set the follow permission:

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"></uses-permission>

My Main.java has the following to make the folder:

public class Main extends TabActivity {
    static int index = 1;
    private static final String TAG = "Main";       

    public void onCreate(Bundle savedInstanceState) {

        File folder = new File(Environment.getExternalStorageDirectory () + "/tallgrass/images");
        boolean success = false;
            success = folder.mkdir();
        if (!success){ 
            Log.d(TAG,"Folder not created.");
            Log.d(TAG,"Folder created!");

I get the "Folder created!" message in my log but when I check both /mnt/sdcard and /sdcard neither one has the folder. I have tried calling:


and it returns true. I just can't figure this one out because all signs are pointing that it should work. I have also tried it with the phone disconnected from the PC in case the SD card was mounting or something as I am currently using my phone instead of the emulator for developing. Speaking of which, does debuggable to true maybe prevent it from making the folder?


share|improve this question
add comment

2 Answers

up vote 26 down vote accepted

Does the /mnt/sdcard/tallgrass/ directory exist? (I'm guessing not, but you never know.)

The File.mkdirs() method will create all needed directories; mkdir() will only create the last directory in the pathname.

share|improve this answer
That's it! I was trying to post an answer as i figured that out moments after I posted but being a new user it wouldn't let me answer my own post. I will check this as soon as it lets me. Thanks! –  Taylor Kems May 11 '11 at 2:41
D'oh! Mostly the automated enforcements here are reasonable enough (and very effective at knocking down spam), but new users sometimes bear the brunt of those restrictions. Anyway, welcome to SO! :) –  sarnold May 11 '11 at 2:44
add comment

Check where you are putting the permissions they must go in this way:

   <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
   <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
   <uses-permission android:name="android.permission.CALL_PHONE" />

<application android:allowBackup="true"

share|improve this answer
add comment

Your Answer


