1

I've been trying to create folder and files on the sd-card of my 4.4.2 android device, but the java.io.File operations have insuficient permissions to do it. File.mkdir() just returns false whenever i write to /mnt/sdcard1.

I've read about google changes in android 4.4 to "support" secondary external storage ( not officially supported before ) and how it end up in devices unable to write to sdcards. I've tryed every way i found to write to the sd-card programatically but whith zero progress so far.

I know that some external apps like "ES File Explorer" can modify the contents of the sd-card at will, so there's must be a way to avoid this permissions problems without rooting the device. ¿ Have someone any idea how they do it ?

Edit:

There are devices, like mine, where internal storage is emulated like an sd card. When you ask for Environment.getExternalStorageDirectory() it returns this emulated sd-card instead the real sd-card. In order to access this secondary sd-card you have to search for it either in /storage or in /mnt.

Since Android 4.4 only applications whith WRITE_MEDIA_STORAGE permission can arbitrarily write to the secondary SD-CARD, but that permission can only be granted to system apps or applications signed by the device manufacturer. There is an adicional way to write, but only in the application folder in the SD /apps/your.app/...

The problem well explained: http://www.chainfire.eu/articles/113/Is_Google_blocking_apps_writing_to_SD_cards_/

The thing is i need to write to an arbitrary folder in the SD, Google, in theory has forbidden this, but there are applications in the Play Store, that can do it, so there's has to be a way to work around that restricction.

aitkiar
  • 273
  • 1
  • 3
  • 12
  • 4
    Check this [Android write to sd card folder](http://stackoverflow.com/questions/3551821/android-write-to-sd-card-folder) – Jordi Castilla Nov 09 '15 at 11:49
  • `I've tryed every way i found to write to the sd-card programatically `. Did you also try `getExternalFilesDirs()' ? You cannot just write on an sd card. Only in specific directories if the manufacturer implemented all ok. – greenapps Nov 09 '15 at 11:53
  • Is there an `/mnt/sdcard1/Android` directory on your device? – greenapps Nov 09 '15 at 11:55
  • 1
    That solution didn't work. There are devices, like mine, where internal storage is emulated like an sd card. When you ask for Environment.getExternalStorageDirectory() it returns this emulated sd-card instead the real sd-card. In order to access this secondary sd-card you have to search for it either in /storage or in /mnt. – aitkiar Nov 11 '15 at 08:28
  • This question should not be marked as a duplicate. It is an old question but I will answer this so it may help others with a similar issue to @aitkiar. I have found it is possible to write to an external SD. This if different to the internal SD found by Environment.getExternalStorageDirectory as aikkiar points out. To write you need to get the folder path for your app folder. For me this located on ".storage/0000-0000/Android/data/com.onsite.myapp/files. I can write to this folder path only. The critical folder to find is Android where there will be a folder for your app to write files too. – ozzyzig Feb 14 '19 at 20:58

0 Answers0