Good day.

I'm trying to create a folder for storing photos from the camera application. I use the code:

File checkDir = new File(Environment.getExternalStorageDirectory() + "/Albums/Application/Images"); if(checkDir.exists()) { Log.v(LOG_TAG, "directory exist"); } else { Log.v(LOG_TAG, "directory NOT exist"); checkDir.mkdirs(); Log.v(LOG_TAG, "directory create"); } 

But all the same, the folder is not created on ext_sd (flash drive), but on the internal memory of the phone (sdcard0).

Already wrote the absolute path, but it works out the root "/" as sdcard0, and then the hierarchy is in my way. Some nonsense comes out.

How to solve the situation?

PS: it is planned to take pictures in the application and store them for display in the same application. The desire to store on a flash drive, as it has more volume.

  • @web_alex, <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> ? - tim_taller
  • Yes, there is permission. - web_alex
  • ===> I tried to find out the status and path to the memory from the log. Log.d (LOG_TAG, "sd path:" + Environment.getExternalStorageState ()); Log.d (LOG_TAG, "sd path:" + Environment.getExternalStorageDirectory ()); Result: 09-11 12: 30: 12.300: D / myLogs (5042): sd path: mounted 09-11 12: 30: 12.300: D / myLogs (5042): sd path: / storage / sdcard0 - web_alex
  • @web_alex, your code is correct, and it creates a folder on the SD card. - tim_taller
  • I test the code on htc desire 600, and you? This device is not root. - web_alex

1 answer 1

I have never used htc desire 600, but (as my experience in using xperia suggests) apparently the device has an internal memory divided into 2 sections:
-internal system partition
-second section mounted as a cdcard (which goes out of the box),
+ slot for external cd card, where you actually want to write (3 section).

Therefore, in this case, Environment.getExternalStorageDirectory () returns the path to the phone’s built-in memory card (2nd section).

The path to the "removable" card can only be obtained from version 4.4 using getExternalFilesDirs , up to 4.4 there is no official support for "removable storage".
here is some info

  • That is, for API <4.4, the recording of photos on the memory card is closed by 1%? Or maybe there is some trick? - web_alex
  • Each device path may differ. You can see a little [here] [1]. [1]: stackoverflow.com/questions/13976982/… - gcoder
  • @gcoder, what a nightmare !! Would introduce a standard one for everyone and it would be ok. Hardcode prescribed and norms. You can, of course, try to set the switch with the parameters and for each manufacturer its own way, but this will be the hardcode of all hardcodes. - web_alex