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

5

47

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.

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 ?

Holding answered 8/2, 2012 at 17:31 Comment(2)
If you have a JSON file that you are worried might be too big, you're doing it wrong.Boxcar
im not worried about the file being too big, im worried that the internal storage that left for the app is too smallHolding
L
46

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.

Librarianship answered 8/2, 2012 at 17:35 Comment(5)
@Holding - How big a file are we talking about here?Librarianship
the file is not big really lets say couple of KB but the thing is if the OS will not reserve anything for my app in some cases then even small files will be a problem.Holding
@Holding - You're worried about a non-problem. If internal storage is so full that there isn't room for a file of a few KB, then the phone isn't going to be working well for just about anything. Just use internal storage and all should be well.Librarianship
@TedHopp If i have 32 Gb device then can my app store data of ~26 GB to its internal memory(data/data/package_name/)? Assuming 6 GB for system data.Lyophilic
@Lyophilic - It all depends on the device, but probably not. Manufacturers can (and, for overall device performance purposes, usually do) put restrictions on the size of the data partition. All that you can expect is that the restrictions meet Google's requirements for whatever version of Android is on the device. The overall memory size of the device is usually irrelevant to how much private memory is available to an app.Librarianship
J
20

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.

Jp answered 8/2, 2012 at 17:59 Comment(3)
keep creating the files and try to go beyond 3.61GB, you will hit the limit. It's apparently there.Elenaelenchus
I stored 4.5 GbHoodlum
I stored 6.86 GB in internal storage on a 64 GB device and it started giving me out of space error, even when I have 10 GB external storage free. So maybe the internal storage limit is around 6.5 GB on a 64 GB device.Nightspot
E
3

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.

Elenaelenchus answered 16/8, 2018 at 14:20 Comment(0)
B
2

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.

Bucephalus answered 21/10, 2018 at 16:28 Comment(3)
I stored 6.86 GB in internal storage on a 64 GB device and it started giving me out of space error, even when I have 10 GB external storage free. So maybe the internal storage limit is around 6.5 GB on a 64 GB device.Nightspot
@Kolitha Can you name a device where you saw a limit?Paripinnate
@AndyJoiner It's been a while now so I don't remember exactly but I believe my observations were on 1. Sony Xperia M2 2. Android 7 official AVDBucephalus
A
0

Update for the Ted's comment;

From the compatibility definition for Android 7.0

Android Television devices MUST have at least 4GB and other device implementations MUST have at least 3GB of non-volatile storage available for application private data.

Argal answered 9/4, 2021 at 7:58 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.