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.
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
android:installLocation="auto"
android:theme="@android:style/Theme.NoTitleBar"
package="com.examplecompany.myapp"
platformBuildVersionCode="23"
platformBuildVersionName="6.0-2704002">
<uses-permission android:name="android.permission.INTERNET"/>
¦
¦
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. |
|
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.
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.
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.
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 installLocation
to preferExternal
in the APK manifest.
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.
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 installLocation
=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 preferExternal
.
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 auto
or preferExternal
as the installLocation
).
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 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!