为应用程序分配的 android 内部存储是否有最大大小? [英] is there a maximum size to android internal storage allocated for an app?

查看:48
本文介绍了为应用程序分配的 android 内部存储是否有最大大小?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I want to save a json file with all the application data (something similar to preference) but im not sure what is the limit size, because if the app cant use this file it will not function probably. is this information known beforehand and the OS reserve some space for your app or its based on the size available.

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

Update: I dont really care about External storage since is not always available in the device and could be changed (SD card) and i could check for internal storage using this but this is not what i want to know, What i want to know if there's a memory size allocated for internal storage for the device ?

推荐答案

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

If you use Environment.getExternalStorageDirectory() (or Context.getExternalFilesDir() for API level 8 and up) as the place for your json file, then I believe the size will be limited by the available space in the external storage (usually an SD card). For most devices, I believe there are no fixed limits built into Android for external file storage. (Internal storage is a different matter. Device manufacturers can impose quite restrictive limits, perhaps as low as 100MB shared among all applications.)

更新:请注意,根据 Android 2.3 兼容性定义(第 7.6.1 节),设备应该有相当多的内存:

UPDATE: Note that according to the compatibility definition for Android 2.3 (Section 7.6.1), devices should have quite a bit of memory:

设备实现必须有至少 150MB 的非易失性存储空间可用于用户数据.也就是说,/data 分区必须至少为 150MB.

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.

除了上述要求之外,设备实现应该至少有 1GB 的非易失性存储空间可用于用户数据.请注意,这更高的要求计划在未来的 Android 版本中成为硬性最低要求.强烈鼓励设备实现满足现在就满足这些要求,否则它们可能无法兼容未来版本的 Android.

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.

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

This space is shared by all applications, so it can fill up. There is no guaranteed minimum storage available for each app. (Such a guaranteed minimum would be worthless for apps that need to store more than the minimum and would be a waste for apps that store less.)

编辑:来自 Android 4.0 兼容性定义

设备实现必须有至少 350MB 的非易失性存储空间可用于用户数据.也就是说,/data 分区必须至少为 350MB.

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.

来自 Android 4.3 兼容性定义

设备实现必须有至少 512MB 的非易失性存储空间可用于用户数据.也就是说,/data 分区必须至少为 512MB.

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 的建议保持不变.

Interestingly, the recommendation that implementations SHOULD provide at least 1GB has stayed the same.

这篇关于为应用程序分配的 android 内部存储是否有最大大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆