0

I have set permission in manifest:

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

I tried create directory with this code:

    // test external storage root
    String myDir = Environment.getExternalStorageDirectory().toString();
    File f = new File(myDir);
    if(f.exists()) {
        Log.d("MyApp", "folder exists: " + f.toString());
    }else {
        Log.d("MyApp", "folder does not exist: " + f.toString());
    }
    // try create folder
    myDir +=  File.separator + "MyFolder";
    f = new File(myDir);
    if(f.exists()) {
        Log.d("MyApp", "folder exists: " + f.toString());
    }else{
        Log.d("MyApp", "folder does not exist: " + f.toString());
        if(f.mkdirs()){
            Log.d("MyApp", "folder created: " + f.toString());
        }else{
            Log.d("MyApp", "cannot create: " + f.toString());
        }

    }

On tablets with Android 4 and 5 is this functionally, but on Nexus 5X with Android 6.0 looks like:

D/MyApp: folder exists: /storage/emulated/0
D/MyApp: folder does not exist: /storage/emulated/0/MyFolder
D/MyApp: cannot create: /storage/emulated/0/MyFolder  

Is in Nexus 5X or Android 6.0 some sweet secret I don't know?

  • Yes, the reason in [Can't Get the Permission](http://stackoverflow.com/questions/32635704/cant-get-the-permission) is right, thank you! But the question couldn't be found until was clear the origin of problem - new permition rules. – Milan Tůma Nov 27 '15 at 12:21
  • I'm sorry, I don't know how to write directly to CommonsWare, so I write it here. I guess this is not duplicate question, this are 2 questions with 1 answer. If I would find solution for sending SMS, I would close it, because I don't want send message, I want to write to storage. Please remove forwarding to another question. – Milan Tůma Nov 27 '15 at 12:54

0 Answers0