I want to create a folder in the internal storage of an android device where I can save my .csv files. But I am unable to create a folder in the internal storage.
Below is my code snippet for creating the folder
fun getStorageDirectory(): File {
    if (Environment.getExternalStorageState() == null) {
        val f = File(Environment.getDataDirectory().absolutePath + "/Afolder/")
        if (!f.exists())
            f.mkdirs()
        return f
    } else {
        val f = File(Environment.getExternalStorageDirectory().absolutePath + "/Afolder/")
        if (!f.exists())
            f.mkdirs()
        return f
    }
}
and this is the permissions I used in my manifest.
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
 
    