Domanda

What exactly does Environment.ExternalStorageDirectory return? I read from the developer docs:

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.

Am I correct in understanding that if my device has a large (16GB) internal memory and no SD Card, this will return the path to the internal memory? Or, do I have to check to see if the SD card is mounted and if not, use the ApplicationContext.FilesDir?

I suppose what I am asking is, if my app needs to download 250MB of data, how do I know where to store it? - As I want to use the "correct" location.

È stato utile?

Soluzione

Am I correct in understanding that if my device has a large (16GB) internal memory and no SD Card, this will return the path to the internal memory?

It will return a path to external storage. On a device with the characteristics you describe, external storage will either be:

  • a separate data partition of that 16GB of on-board flash (Android 2.x), or
  • a directory within the main data partition of that 16GB of on-board flash (Android 3.0+)

Or, do I have to check to see if the SD card is mounted

External storage may be mounted on a host PC, regardless of whether external storage is represented by an SD card, a portion of on-board flash, or pixie dust.

On Android 2.x, if external storage is mounted on a host PC, it is unavailable to your application. Hence, if you are supporting Android 2.x, you need to check whether external storage is available, regardless of how that external storage is implemented.

I suppose what I am asking is, if my app needs to download 250MB of data, how do I know where to store it?

Put it on external storage. If external storage is not available, do not download the data and tell the user to unmount their phone from their host PC. There are many Android 2.x devices which do not even have 250MB of internal storage for all apps combined, let alone for just your use.

Altri suggerimenti

Here is another stackoverflow thread. Hope it will work for you.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top