-1

I tries to create a new folder in External storage SD Card. Using this code:

val folderMain = "NewFolder"
val f = File(Environment.getExternalStorageDirectory(), folderMain)

if (!f.exists()) {
    f.mkdirs()
}

and this permission:

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

But after executing this code It creates a new folder in Internal storage. Here is the screenshot of Internal Storage:

enter image description here

While External Storage has no new folder in it. Here is the screenshot of External Storage:

enter image description here

What should I do? I want to create a new folder in External storage By using Kotlin or java codes.

1 Answers1

0

From https://developer.android.com/reference/android/os/Environment.html#getExternalStorageDirectory()

Note: don't be confused by the word "external" here. This directory can better be thought as media/shared storage. It is a filesystem that can hold a relatively large amount of data and that is shared across all applications (does not enforce permissions). Traditionally this is an SD card, but it may also be implemented as built-in storage in a device that is distinct from the protected internal storage and can be mounted as a filesystem on a computer.

leonardkraemer
  • 6,573
  • 1
  • 31
  • 54