Mobile and living room devices today present a varied landscape for developers to consider. One aspect that is particularly meaningful for your customers is where your app installs itself. Some devices, like the current Fire tablets and Fire TV have external storage through memory card slots. Other devices, like Fire TV Stick or older Fire tablets have only their internal flash storage. Running out of storage when trying to install a new app can be very frustrating for people who want to use your app. This frustration is compounded for customers who have added a memory card with lots of empty space and still get an error message that the device is out of space when trying to install. That frustration can quickly find its way into negative reviews for your app.
Luckily, for most apps, Android provides a simple solution. By specifying the
installLocation in the app manifest, you can provide your user community with the best experience possible for whatever device they own. This doesn't mean they'lll never run out of space, but it helps best manage the space they have.
installLocation can be specified as any of the following:
Install the app to internal storage. If there is not enough room in internal storage, the install will fail. The app cannot be manually moved later by the user.
Install to internal storage by default, but if internal storage is full, install the app to external storage, if it is available. The user can manually move the app later by selecting it from Settings > Apps & Games > Manage All Applications.
Note: for Amazon devices, see the note in the section "Fire tablets external storage settings", below.
Install to external storage by default, but if external storage is full, install the app to internal storage, if it is available. The user can manually move the app later by selecting it from Settings > Apps & Games > Manage All Applications.
If you don't specify
installLocation in the
<manifest> element of the appmanifest.xml, the app will be installed to internal storage and cannot be moved to external storage, just as if you specified
internalOnly. This default behavior is functional, but is really the most frustrating for customers using your app on devices that support external storage.
Certain types of applications should never be installed to external storage.
- Alarm Services
- Input Method Engines
- Account Managers
- Sync Adapters
- Device Administrators
- Broadcast Receivers listening for "boot completed" message
- Live Wallpapers (not supported on Fire OS)
- App Widgets (not supported on Fire OS)
What ends up where?
Even when an app is installed on external storage, the databases, extracted native code, private user data, and processed .dex files will always be on internal storage. This can be confusing to customers when they run out of internal storage while having available external storage and installing apps to external. Unfortunately, this is just a fact of life with Android.
Specifying install location with Unity
Unity is one of the most popular tools for creating games for the Amazon Appstore. Unity supports setting the install location through the Player Settings Inspector for Android.
- From your Unity project, click File-Build Settings...
- From the Build Settings dialog, select "Android" in the Platform list and click the Player Settings... button to display the inspector:
- Open the "Other Settings" section and look for the "Install Location" setting. You'll notice
preferExternal is the default, which is almost always the best choice.
YoYo Games' Gamemaker:Studio also uses
preferExternal as the default for Android projects. This can be changed by manually editing some underlying files, but
preferExternal is really what you want to use for games.
Other engines and development frameworks provide similar options. Consult the documentation for the tool you are using to make sure you are using are configured to set the
preferExternal in the APK manifest.
Handling secondary downloads in your app
Some applications, particularly games, use secondary downloads containing additional textures, levels, or other, generally asset, files. If you are handling this download in your app code, such as part of first run initialization, you should use the Android
PackageManager getApplicationInfo method to retrieve the
ApplicationInfo class. This class contains the location of the APK (
sourceDir) and the public parts of the source directory, including the resources and manifest(
publicSourceDir). If the app has been installed on external storage, these paths will point to that location and indicates where you should install the additional downloaded content.
If an app uses
installLocation=preferExternal to install the 40MB APK onto external storage, but then stores a 1GB downloaded data file to internal storage, perhaps because they use the
ApplicationInfo dataDir path, obviously this is not a good thing for the customer using the app.
Fire tablets external storage settings
When a Fire OS 5 tablet detects an external storage card, the Storage page in Settings will show an option for "Install supported apps on your SD card", which defaults to "on".
When active, this setting effectively reverses the standard Android behavior of
auto such that
auto will act like
preferExternal on Amazon devices. This is a step forward for customers using these devices, but the best choice for all Android devices, including those from Amazon, is to specify
Fire OS tablets, like other current Android devices, also allow the user to move apps between internal and external storage (as long as they specify either
preferExternal as the
As indicated in the "What ends up where?" section, above, regardless of how an app gets on external storage, there is still an impact on internal storage as well. In this example, you can see the footprint of an app on internal storage even after moving it to external.
Fire TV external storage settings
Fire TV 2014 supports USB external storage and Fire TV 2015 includes a microSD slot for external storage. On these devices, settings are provided to manage connected external storage.
There are two recommendations to keep in mind.
First, in most cases, you should specify
preferExternal as the
installLocation in the app manifest. This provides all of your Android customers with the best experience whether they have added an external storage card or not.
Second, for apps that perform their own secondary downloads as part of first run or at any other time, these downloaded files should be stored where the APK file was installed on the device. If the app is installed on external storage, the APK file will be on external storage.
Happy customers with more space will fill them with more of your apps, which makes for happy developers too!
Other helpful links