android 中的 SD 卡存储空间

SD card storage in android

如果已经解释过了,请原谅。

我使用文件路径作为 Environment.getExternalStorageDirectory()+"/myfolder/myfile.img用于存储具有清单权限的文件。对我来说工作正常。

我对这行代码有一些疑问。

  1. 我注意到这在内部存储器中创建了一个文件夹,怎么样 如果内存不够space?

  2. 如果外置SD卡内存足够怎么办?

  3. 会自动在外置存储卡中创建文件夹吗?

提前致谢。

从这里开始: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) 如果你没有捕捉到异常,你的应用就会崩溃
2) 同 1.
3) 不!

看看: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.

根据设备的不同,您的文件将放置在 SD 卡或内部存储器上。

如果没有空闲 space 可用,任何写入数据的 IO 操作都会失败。