is there a maximum size to android internal storage allocated for an app?

前端 未结 4 1504
小鲜肉
小鲜肉 2020-12-01 07:43

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 w

4条回答
  •  感情败类
    2020-12-01 07:52

    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.)

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

    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.

    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.)

    Edit: From the 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.

    From the 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.

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

提交回复
热议问题