skip to Main Content

I’m new at this.

Telegram, Whatsapp, Vk, Aliexpress – All this apps can write they folders in /Storage/emulated/0

How can I create my folder in this place for Android 5…10?

When I try to use File("/storage/emulated/0/", myfile) – it doesn’t work.

Please, can anyone give some mini example how can I create my files in storage

3

Answers


  1. Since you haven’t written any code, I can’t tell you what you’re doing wrong. But this is something that might help you.

    Login or Signup to reply.
  2. First you need to declare permissions on your manifest.

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

    After that you can simply use this to create your folder.

        String path = Environment.getExternalStorageDirectory().getAbsolutePath() + "/" + 
        "folderName";
    
        File directory = new File(path);
        directory.mkdirs(); // It returns a boolean you can use it to check if your folder 
                            // was created.
    
    Login or Signup to reply.
  3. Yes, You can create Folders inside the External Storage too.
    But, keep in mind that you cannot use emulated/0 because it is different for different devices.

    File path = new 
    File(Environment.getExternalStorageDirectory().getAbsolutePath()+"/Folder/");
    if(!path.exists()){
            boolean k = path.mkdirs();
        }
    

    Although, Environment.getExternalStorageDirectory() is deprecated as of API29. So You can use getExternalDir() too.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search