How to create a directory in Android?

前端 未结 4 1010
礼貌的吻别
礼貌的吻别 2021-01-13 05:16

Everything is in the question. Here is my code :

    private void createDirectory(File currentDirectory) {
  File f = null;
  try {

   f = new File(current         


        
4条回答
  •  [愿得一人]
    2021-01-13 05:19

    You have to add this permission:

    
    

    By the way, not sure how you are getting the SDcard directory... but it must be this way:

    File sdDir = Environment.getExternalStorageDirectory();
    

    It's important, because some programmers use to think that the SDCard is always /sdcard, but it could change.

提交回复
热议问题