The following code works when I either have no min sdk version
specified in the app manifest or if it's 5 or greater.  But if I set
the min sdk level to 4 (Android 1.6) , it fails to create a
subdirectory in the sdcard.  There is no error.  mkdir() or mkdirs()
just returns false.

    String msg;
    try {
        String theState = Environment.getExternalStorageState();
        if (theState.equals(Environment.MEDIA_MOUNTED)) {
            File theBasedir =
Environment.getExternalStorageDirectory();
            File theSubdir = new File(theBasedir, "subdir");
            boolean created = theSubdir.mkdirs();
            msg = theSubdir.exists() ? "Success" : "Fail";
        } else {
            msg = "Invalid State";
        }
    } catch (Exception e) {
        msg = "Error - " + e;
    }
    System.out.println(msg);

Am I doing something wrong here?  Or is this a bug?  I'd prefer not to
set the target to 2.1 and min version to 1.6.  But right now, I have
to set it to 2.0 for it to work.

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to