can't create folder programmatically on external storage - Android

前端 未结 2 1566
野的像风
野的像风 2021-01-07 09:07

This is my code:

boolean success = false;
Log.d(TAG, Environment.getExternalStorageDirectory() + \"/\" + Environment.DIRECTORY_PICTURES + \"/myFolder\" );
my         


        
相关标签:
2条回答
  • 2021-01-07 09:26

    You should Use This Permission in your mainfest file.

    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
    
    0 讨论(0)
  • 2021-01-07 09:29

    I'm not sure just try to create folder like below -

    success = myFolder.mkdirs();
    

    instead of

    success = myFolder.mkdir();
    

    as per mkdirs() And, don't forget to add the below permisstion into your manifest file.

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

    Also have a look at this answer - How to create directory automatically on SD card

    0 讨论(0)
提交回复
热议问题