Make directory in android

后端 未结 8 692
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-13 17:40

Im trying to build a directory called \"images\" on the SD card on android. This is my code but its not working? Can anyone give me some advice?

File picDire         


        
8条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-13 18:20

    To create specific root directory and its sub folder i use this code

    String root = Environment.getExternalStorageDirectory().toString();//get external storage
    
    File myDir = new File(root + "/grocery"+"/photo/technostark");//create directory and subfolder
    
    File dir=new File(root + "/grocery"+"/data");//create subfolder
    
    myDir.mkdirs();
    
    dir.mkdirs();
    

提交回复
热议问题