android - 为应用程序分配的 android 内部存储是否有最大大小?

标签 android storage android-sdcard

我想保存一个包含所有应用程序数据的 json 文件(类似于首选项),但我不确定限制大小是多少,因为如果应用程序无法使用此文件,它可能无法运行。是否事先知道此信息,并且操作系统会根据可用大小为您的应用程序或应用程序保留一些空间。

更新: 我并不真正关心外部存储,因为设备中并不总是可用并且可以更改(SD 卡),我可以检查 internal storage using this但这不是我想知道的,我想知道是否为设备的内部存储分配了内存大小?

最佳答案

如果您使用 Environment.getExternalStorageDirectory() (或 Context.getExternalFilesDir() 对于 API 级别 8 及更高版本)作为 json 文件的位置,那么我相信大小将受到外部存储(通常是 SD 卡)中可用空间的限制。对于大多数设备,我相信 Android 中没有针对外部文件存储的固定限制。 (内部存储是另一回事。设备制造商可以施加相当严格的限制,可能低至所有应用程序共享的 100MB。)

更新:请注意,根据 compatibility definition for Android 2.3 (第 7.6.1 节),设备应该有相当多的内存:

Device implementations MUST have at least 150MB of non-volatile storage available for user data. That is, the /data partition MUST be at least 150MB.

Beyond the requirements above, device implementations SHOULD have at least 1GB of non-volatile storage available for user data. Note that this higher requirement is planned to become a hard minimum in a future version of Android. Device implementations are strongly encouraged to meet these requirements now, or else they may not be eligible for compatibility for a future version of Android.

此空间由所有应用程序共享,因此可以填满。没有保证每个应用程序可用的最小存储空间。 (这样的保证最低限度对于需要存储超过最低限度的应用程序来说毫无值(value),而对于存储量较少的应用程序来说则是一种浪费。)

编辑:来自compatibility definition for Android 4.0

Device implementations MUST have at least 350MB of non-volatile storage available for user data. That is, the /data partition MUST be at least 350MB.

来自 compatibility definition for Android 4.3

Device implementations MUST have at least 512MB of non-volatile storage available for user data. That is, the /data partition MUST be at least 512MB.

有趣的是,实现应该提供至少 1GB 的建议保持不变。

关于android - 为应用程序分配的 android 内部存储是否有最大大小?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9198440/

相关文章:

jquery - 如何计算两个地理位置之间的角度?

Android Marshmallow(已root): How to read/write any file

java - 转到 Android Studio 2.1 后呈现问题

Android 应用程序数据,用户可以访问/编辑吗?

javascript - 如何为 Firefox 插件初始化 SQLite 文件?

android - 如何在安装过程中将文件从 Assets 复制到 SD 卡

java - android postgresql数据库连接错误

javascript - Ionic 2 - LocalStorage 或应用程序中的 Json 存储

android - 当应用程序被强制移动到 SD 卡时,SharedPreferences 去哪里了?

android - 如何从 SD 卡读取 json 文件