Software Development

Use installLocation to help out older Android devices

A simple line in your Android app's manifest can save much user frustration.

When people do not grok Android, and then go about making apps, it often shows.

Unless an application is a vital system replacement, such as a keyboard, or is a Service, then there really is no reason why an application cannot reside on an Android device's external storage, if it exists. (A full caveat list for not installing on external storage can be found here.)

As the years have gone by, this inability of many applications to allow movement to external storage has become quite frustrating — and it all extends from a quirk of Android device designs' past.

If you have only experienced an Android phone that has been released in the past two years, then you would not have come across the feature called "internal storage".

Take the Samsung Galaxy S2, for example: Even though a phone is advertised with 16GB of internal storage, 2GB of that storage is claimed by Android for "system" purposes, leaving the rest for the user to do whatever they like with.

Sometimes, though, much of the free space on the internal storage is claimed by log or tombstone files that can eat away at the storage until users can no longer install apps without an error.

Even though the user's SD card and USB storage (what the rest of the un-system internal storage is called) may have gigabytes free, an amount of internal storage is needed to install or update apps. The result is that users end up in a dreaded place where an "Insufficient storage available" error occurs when trying to install/upgrade an application — all because that internal storage is under root control and cannot be cleared out by your average user.

A factory reset or rooting the phone are ways to get the internal storage back under control, but the average user will not do these things.

One way to help them out is to set the installLocation property in your Android app's manifest.

By default, Android picks a value of "internalOnly", which forces applications to be installed onto internal storage, and to never be installed on external storage. If the internal storage is full, it will not install or update the app.

This is an approach that will have your app cursed and sworn at when it takes up a Vine-like 50MB of precious space and refuses to be moved to external storage.

Therefore, for most apps, you should set the installLocation property, and set it to "auto" or "preferExternal". The former will target internal storage first, but allow movement to the external storage later on; the latter will aim at external storage first, and fall back to internal if needed.

It's a simple one line, but it can help a frustrated Android owner either clear some storage space or avoid your app being uninstalled in a vicious cycle of uninstalling to clean up a phone's internal memory.

About

Some would say that it is a long way from software engineering to journalism, others would correctly argue that it is a mere 10 metres according to the floor plan.During his first five years with CBS Interactive, Chris started his journalistic advent...

0 comments

Editor's Picks