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

前端 未结 4 1480
小鲜肉
小鲜肉 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:51

    There is definitely a cap around 3.5 GB per app in /sdcard/Android/data/, at least on certain devices. This also applies to the images provided by Google for the official Android Emulator. I noticed this when I repeatedly got "out of disk space" errors in a certain Android app built with Unity that downloads a lot of image, video, audio data. Each time it happened when the folder in the aforementioned location grew to around 3.5 GB. No amount of clearing space will fix this. There seems to be zero documentation about this behaviour, however.

    0 讨论(0)
  • 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.

    0 讨论(0)
  • 2020-12-01 08:03

    I've never witnessed it limit a single application, and I have tested it with saving some rather large (200 mb) video files in the app Files dir before.

    For internal storage I think your only limited by the amount of internal storage made available for all applications to share. Which as @Ted Hopp mentioned is rather small on some of the older and lower end devices. But on the newer and higher end devices they've started bumping it up to a reasonable amount, though even if the device has a lot of space, it could still be taken up by other applications(so you need to test what will happen in this scenario).

    It is also worth pointing out that if you use external storage such as the SD card then your json file would technically editable by the user. They could open it up in a text editor and start changing the raw values if they had any desire to. (This is also possible if you choose to use internal storage, but it would require a rooted device, whereas if it is stored on the SD card would not require root)

    So if you are storing info that you'd rather the user not have the option to manually edit, you may want to take that into consideration.

    0 讨论(0)
  • 2020-12-01 08:12

    I think there is a hard limit of about 3.61GB.

    I currently have termux installed on my tab. Termux runs a linux terminal where i can install nodejs and npm. Thereby essentially creating a development environment. I have installed packages without much space-related problems except when my device's internal memory is realy low. But as of recent. I think I have reached that limit, which brought me to this question and hit on this page.

    My device storage is way beyond 1GB and I have used it with space as low as 200MB without this issue. But my termux installation has grown to 3.61GB. I recently started with yarn and it seems like yarn is a space hog. I was installing a package and it suddenly logged: error Could not write file "/data/data/com.termux/files/home/dev/ide/theia/yarn-error.log": "ENOSPC: no space left on device So it crushed the installation and thought i really ran out of space, but I hadn't. Further inspection shows that i still have the aforementioned space in internal storage and yarn has hogged 750MB, of which npm only about 500MB in cache. I have been using npm since, but just needed to use yarn as the installation for Theia wasn't finishing well with npm. Theia seems to be using yarn as their package manager. So 3.61GB hints to be the hard limit for app + data.

    Removing some packages and reducing some space used by other redundant packages, I gain space to create files and install as I please, but as soon as I reach 3.61GB again!!! boom!!! that's it, I can't create any files anymore.

    I don't think this is well-documented, but it is happening.

    I am using lollipop (android 5.1)

    To assert this, someone else should try to use an app that creates really large files in its internal sandbox. Not in the internal storage, but in its private data area. I am sure you will likely hit this hard-limit.

    0 讨论(0)
提交回复
热议问题