内部/SD卡的Environment.ExternalStorageDirectory
Environment.ExternalStorageDirectory
到底返回什么?我从开发人员文档中读到:
注意:不要对这里的“外部”一词感到困惑。该目录可以更好地被视为媒体/共享存储。它是一个可以容纳相对大量数据并且在所有应用程序之间共享的文件系统(不强制执行权限)。传统上,这是一张 SD 卡,但它也可以实现为设备中的内置存储,与受保护的内部存储不同,并且可以作为文件系统安装在计算机上。
如果我的设备有大容量(16GB)内部存储器并且没有 SD 卡,这将返回内部存储器的路径,我的理解是否正确? 或者,我是否必须检查 SD 卡是否已安装,如果没有安装,请使用 ApplicationContext.FilesDir
?
我想我要问的是,如果我的应用程序需要下载 250MB 的数据,我如何知道将其存储在哪里? - 因为我想使用“正确”的位置。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
它将返回外部存储的路径。在具有您描述的特征的设备上,外部存储可以是:
外部存储可能已安装在主机 PC 上,无论外部存储是否由 SD 卡、板载闪存的一部分或精灵灰尘表示。
在 Android 2.x 上,如果外部存储安装在主机 PC 上,则您的应用程序将无法使用它。因此,如果您支持Android 2.x,则需要检查外部存储是否可用,无论外部存储是如何实现的。
将其放在外部存储上。如果外部存储不可用,请不要下载数据并告诉用户从主机 PC 上卸载手机。许多 Android 2.x 设备甚至没有 250MB 的内部存储空间供所有应用程序使用,更不用说供您使用了。
It will return a path to external storage. On a device with the characteristics you describe, external storage will either be:
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.
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.
这是另一个 stackoverflow 线程。 希望如此会为你工作。
Here is another stackoverflow thread. Hope it will work for you.