gpt4 book ai didi

android - 内部/SD 卡的 Environment.ExternalStorageDirectory

转载 作者:太空狗 更新时间:2023-10-29 12:53:48 24 4
gpt4 key购买 nike

Environment.ExternalStorageDirectory 究竟返回了什么?我从开发者文档中读到:

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.

如果我的设备有大内存 (16GB) 而没有 SD 卡,我的理解是否正确,这将返回到内存的路径?或者,我是否必须检查 SD 卡是否已安装,如果没有,请使用 ApplicationContext.FilesDir

我想我想问的是,如果我的应用程序需要下载 250MB 的数据,我怎么知道将它存储在哪里? - 因为我想使用“正确”的位置。

最佳答案

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?

它将返回外部存储的路径。在具有您描述的特征的设备上,外部存储将是:

  • 16GB 板载闪存的单独数据分区 (Android 2.x),或
  • 16GB 板载闪存 (Android 3.0+) 的主数据分区内的目录

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

外部存储可以安装在主机 PC 上,无论外部存储是由 SD 卡、一部分板载闪存还是小 Sprite 灰尘表示。

在 Android 2.x 上,如果外部存储安装在主机 PC 上,则您的应用程序无法使用它。因此,如果您支持 Android 2.x,则需要检查外部存储是否可用,无论该外部存储是如何实现的。

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

把它放在外部存储上。如果外部存储不可用,请不要下载数据并告诉用户从他们的主机 PC 上卸载他们的手机。许多 Android 2.x 设备甚至没有 250MB 的内部存储所有应用组合,更不用说仅供您使用了。

关于android - 内部/SD 卡的 Environment.ExternalStorageDirectory,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9052261/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com