Help me to understand. I'm trying to just create a folder with subfolders in the sdcard root.

new File(path).mkdirs(); 

path - / storage / sdcard1 / GetGeo / backups / 160516164519

mkdirs always returns false (folder is not created)

prescribed in the manifesto

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

screen of what gives adbshell screen of what gives adbshell

through it I can create a folder via adbshell I can create a folder

Help me to understand

  • why may not work
  • how to solve a problem

A similar algorithm with path - / storage / sdcard0 / GetGeo / backups / 160516164519 (i.e., internal memory) works (i.e. all folders and subfolders are created)

On the hands while two devices 5.1.1 and 5.1 and on both the problem. We know about requestpermissions on 6+. So far, I only checked for android below 6

  • Try new File (Environment.getExternalStorageDirectory (), "test-folder"). Mkdirs (); So just create in the root folder test-folder. Will it work out? - Android Android
  • @ Android Android Environment.getExternalStorageDirectory () always returns / storage / sdcard0 Exactly 0 ie Internal memory, but I need to accurately write to the sdcard if it is or not to write at all (such a task). So in / storage / sdcard0 I can create new folders (this clarification is in the body of the question). Those. code New File (Environment.getExternalStorageDirectory (), "test-folder"). mkdirs (); will succeed in my case (in response to your question), but this will not solve my problem - Stanley Wintergreen

1 answer 1

Summed up for myself so far:

I can write in private on sdcard, for example /storage/sdcard1/Android/data/my.awesome.package/ , but I can’t get to the root of the card yet

Actually for devices with android 5+

Update: it turned out to be private I can only write on some devices, for example on Xperia c4 I can’t create a private folder on the flash drive

Update 2: for unknown reasons, a problem on the Xperia c4 helped restart the phone O_o