I recently modified all my apps to run on an SD card by specifying
android:installLocation="preferExternal" in the Manifest.xml. They tested out just fine on all my test phones.
It seems like a no-brainer for an app to allow this. But I notice that most of the apps on my phones do not allow running on an SD card. Google Chrome, Google Earth, Dropbox, Google Gmail, GolfNow, etc. In fact none of the Google apps will run on an SD Card.
I'm trying to find out why. What is the downside of running on an SD card?
Thanks,
Dean
This is actually a broad question and you'd really have to ask the developers of those apps to get a definitive answer.
Some ideas...
External storage as it's traditionally known was usually provided by plug in SD cards. An SD card can, of course, be dismounted and/or physically removed by the user meaning none of the apps installed on it will work until it is reinserted.
Certain types of RAM chips have much faster access times than others. Internal RAM on a device might be better suited for processor / computational intensive apps than that of accessing SD cards which tend to have slower access times both at the RAM chip level and also due to having to go through an external bus.
Mission critical apps (depending on the users' defination of what they should be) need to be accessible permanently (see my first point). If a user wants their email to be retrieved at short, fixed intervals, their email app can't be allowed to disappear because the external storage has been dismounted / removed.
There are known problems with some app requirements which cause unpredictable results when the app is installed on an SD card. A classic example is any app which registers a BroadcastReceiver to receive the BOOT_COMPLETED action. Boot completion happens BEFORE various parts of a device are up and running - this includes mounting the SD card. In this scenario, the broadcast is sent but the apps on the SD card aren't running and can't receive it.
As time has gone on, so called 'internal' and 'external' storage definitions have become increasingly blurred - in comparison to several years ago, many Android devices have huge amounts of 'internal' memory making it less important to free up space by installing or moving apps to 'external' storage. Some devices don't even have the ability to add an external SD card and 'external' storage is emulated from a partition on the 'internal' storage.
One other point (tongue in cheek) - perhaps the developers of the apps you mention are egomaniacs and just insist on using up precious 'internal' storage just because they can. ;)
What is the downside of running on an SD card
Depends on the app. If i.e. your app listens to broadcasts, uses Alarm Manager etc. then it must not be on SD card for this to work. If your app is not using any of these, then it simply makes no difference from developer standpoint.
Related
I have a question regarding the (free) available space in Android. If I open my Android settings, I can see that my external SD card has about 9GB of free space. But if I do some calculations in an Android application, I only get 1GB out of it. I'm using the following lines:
double freeSpace = stats.getAvailableBlocks() * stats.getBlockSize() / 1024;
and
Environment.getExternalStorageDirectory().getUsableSpace();
What's the reason for this? I just want to get the available space on my SD card that I can use.
On most modern Android devices, external storage is the part of the built-in flash that is accessible via a USB cable. While a long time ago external storage tended to be implemented via micro SD cards, that has not been the case in ~4 years and is rather rare today. Hence, getExternalStorageDirectory() is probably not what you want.
If your device is running Android 4.4+ — particularly if it shipped with Android 4.4+ — then if getExternalFilesDirs() returns 2+ entries, the second and subsequent locations are on removable storage. In principle, you could use those with your techniques from your question to try to determine the free space on the card. That being said, I have no idea if this works, as I have never tried it.
On the whole, removable media is mostly there for the benefit of device manufacturers and pre-installed apps, not ordinary SDK apps.
Some of the newer devices coming out from Google do not include an sd card, and it appears they are moving towards this direction.
My question: Is there a way to declare the sd card as a uses-feature to prevent people without an external storage from seeing/downloading the app from Google Play?
I realize this is not the correct way to address the issue, but until i can re-code my apps to anticipate this, I am hoping there is a filtering option in the manifest?
There is no <uses-feature> which does what you want.
What you could do is manually select the devices within your developer dashboard on Google Play. I know this is very inefficient and will probably take a lot of time but it's the only way of achieving exactly what you want.
If you don't want to bother with that then i would recommend that you include this information in your app's description on Google Play and on top of that handle the situation when your application is started up for the first time (for example inform the user that the device is not supported because it has no external storage).
I don't know if such a feature exists, and even if it did it would be difficult to use. I have a Samsung Galaxy Nexus, and while it doesn't have an SD card per-say, it does have 16GB of internal storage. I have seen other phones that say "Internal SD Card" so it really depends on whether that feature (if it exists) can tell the difference between the two. Some devices also have an actual SD card that's hidden from the user, and so they aren't able to tell it's there. Most devices now also have a decent amount of internal storage, so I'm not sure why it's an issue. Do you even need to re-code your application for that? I would think that android would realize that you're requesting storage space that's unavailable and would tell notify the user that they need more storage. All android phones have some amount of internal storage available to the user.
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 ?
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.
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.
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.
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.
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.
HTC incredible, no SD card only internal memory. my app uses MediaStore.Images.Thumbnails.getThumbail() to retrieve image thumbnails. looking at the code, Thumbnails hard codes the external storage URI in its impl!
worse, MediaStore is final so it can't be extended, and it uses internal SDK calls so it can't be copied.
Is anyone aware of a workaround for this? worst case is I need to factor out what i need from Thumbnails and maintain it myself. highly undesirable.
android Thumbnails.getThumbnail() and phones w/o ext storage
All Android devices with the Android Market have at least 2GB of external storage when they ship. Whether or not that storage is available at any given moment may vary.
HTC incredible, no SD card only internal memory.
The HTC Droid Incredible has external storage. It is not an SD card. External storage does not mean "removable storage", but rather storage that can be mounted by the user as a drive/volume on their desktop or notebook.
my app uses MediaStore.Images.Thumbnails.getThumbail() to retrieve image thumbnails.
One presumes you are encountering problems with this. It is often useful to explain your problem if you expect to get help in resolving it.
looking at the code, Thumbnails hard codes the external storage URI in its impl!
Looking at the code, I'm not seeing where this hard-coding is occurring. There is no reference to sdcard anywhere in MediaStore. Consider in the future using a hyperlink to point to such resources.
worse, MediaStore is final so it can't be extended, and it uses internal SDK calls so it can't be copied.
None of that would do you any good, considering that you cannot replace the MediaStore except via a complete firmware replacement.
is anyone aware of a workaround for this?
Possibly, but since you declined to explain what "this" is, it is impossible to answer your question.
UPDATE based upon comments:
I own an HTC DROID Incredible. /mnt/sdcard/ is user-writeable. I wrote a program that wrote to it. If you know how to program, you might try writing a program that writes to it -- be sure to hold the WRITE_EXTERNAL_STORAGE permission. The permission bits (which are 075 for my /mnt/sdcard/) aren't especially relevant for external storage on Android 1.x/2.x devices AFAIK, because external storage is vfat on those OS versions and therefore do not really honor Linux permissions.
With respect to EXTERNAL_CONTENT_URI, that turns into a content:// Uri, which does not "hard codes the external storage".
A year later it seems that 2.3+ versions of Android no longer use the INTERNAL_CONTENT_URI for user media; existence of an external SD card is irrelevant. Of all android models I have the INTERNAL_CONTENT_URI is only used for system apps, and HTC devices use it for tutorials and other weird media files. All photos and videos taken from the camera, all downloads, and every other media type I've seen will save to the EXTERNAL_CONTENT_URI. I feel confident in saying the INTERNAL_CONTENT_URI can now be completely avoided, and just using the EXTERNAL_CONTENT_URI will retrieve all user media; at least anything that the user will be interested in.
Some devices I've worked with include the HTC Thunderbolt, the HTC Droid DNA, the Galaxy Nexus, and the Samsung Galaxy S3. Samsung devices rarely ever use the INTERNAL_CONTENT_URI, and I have yet to see anything on Nexus devices. The only modern device I've seen that still uses it is HTC devices, but to reiterate and conclude there is absolutely nothing useful to the user stored in the INTERNAL_CONTENT_URI on HTC devices.
Can I store web pages on an Android device that lacks a microSD slot, so I can deliver an offline demo?
I asked a similar question a little while ago, but I assumed the device I was thinking of buying HAD a microSD slot -- but now I'm afraid it might not. The device in question is the Samsung Galaxy Tab 10.1, due out next week. Earlier demo models had a microSD slot, but although the specs are not entirely clear, it looks like the production version might not. If it lacks a microSD slot, will I somehow be able to save the demo in internal memory, or will I be out of luck?
Thanks for your help!
Typically there is a storage space on the device, however it is not really usable. When you plug the device into a computer you are actually storing and accessing files on the sdcard. However if this device does not have an sdcard then there is a high chance that it would allow you to store files on the internal flash storage. You could then access these files to give a demo just like if you had an sdcard.
Looks like the new Galaxy Tab 10.1 comes with between 16 and 32gb of internal flash memory. Though failing to include a MicroSD slot in the first place is unusual, it's highly unlikely that they won't allow you to use some of that 16+GB for your own files. That would mean you'd be unable to copy MP3s to the device via USB, for example, which would annoy a lot of people.
Part or all of the 16+GB should be partitioned and made available for your use.