Android file-creation fails.
- by Alxandr
I use the following code to create a folder "mymir" and a file ".nomedia" (in the mymir-folder) on the sdcard of an android unit. However, somehow it fails with the exception that the folder the ".nomedia"-file is to be placed in dosn't exist. Here's the code:
private String EnsureRootDir() throws IOException
{
    File sdcard = Environment.getExternalStorageDirectory();
    File mymirFolder = new File(sdcard.getAbsolutePath() + "/mymir/");
    if(!mymirFolder.exists())
    {
        File noMedia = new File(mymirFolder.getAbsolutePath() + "/.nomedia");
        noMedia.mkdirs();
        noMedia.createNewFile();
    }
    return mymirFolder.getAbsolutePath();
}