简体   繁体   中英

SD card storage in android

Please excuse me if this was already explained.

I am using file path as Environment.getExternalStorageDirectory()+"/myfolder/myfile.img for storing file with manifest permissions .It is working fine for me .

I have some queries regarding this line of code.

  1. I noticed that this creates a folder in internal memory, what about if there is no enough space in internal memory?

  2. And what about if there is enough memory in external SD card?

  3. Will it automatically create folder in external memory card?

Thanks in advance.

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

Return the primary external storage directory. This directory may not currently be accessible if it has been mounted by the user on their computer, has been removed from the device, or some other problem has happened. You can determine its current state with getExternalStorageState().

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.

1) you app crashes if you not catching exceptions
2) sames as 1.
3) no!

Take a look at: http://developer.android.com/reference/android/os/Environment.html#getExternalStorageDirectory()

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.

Depending on the device your file will be placed on the sdcard or the internal storage.

If no free space is available any IO action which writes data will fail.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM