App Install Location

Have you ever seen error saying "Application cannot be installed in the default install location" when trying to update apps?

Many devs have nexus devices, and they haven't sd card.
Move to SD card is the feature which is introduced in Android 2.2. (API Level: 8).


Add android:installLocation attribute to manifest tag as follows:
<!--xml version="1.0" encoding="utf-8"?-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="it.gmariotti.apps.quakes"
    android:versionCode="1"
    android:versionName="1.0" 
    android:installLocation="auto">

    <uses-sdk
        android:minSdkVersion="7"
        android:targetSdkVersion="17" />
    ....
The attribute android:installLocation can have following possible values.
  • internalOnly: The application must be installed on the internal device storage only. If this is set, the application will never be installed on the external storage. If the internal storage is full, then the system will not install the application. This is also the default behavior if you do not define android:installLocation.
  • auto: The application may be installed on the external storage, but the system will install the application on the internal storage by default. If the internal storage is full, then the system will install it on the external storage. Once installed, the user can move the application to either internal or external storage through the system settings.
  • preferExternal: The application prefers to be installed on the external storage (SD card). There is no guarantee that the system will honor this request. The application might be installed on internal storage if the external media is unavailable or full, or if the application uses the forward-locking mechanism (not supported on external storage). Once installed, the user can move the application to either internal or external storage through the system settings.
The build target needs to be updated to at least API Level 8, while android:minSdkVersion can be lower than 8 (on the phones having Android below 2.2 app still works but the button Move to SD card will be grayed out).

Be careful with this option, Not all apps can be moved in SD. Although users may not remove their SD cards frequently, the SD card is unmounted when it’s mounted via USB for use on a computer. This will potentially increase the frequency that the user will have to reconfigure apps that are affected.

You can find further details here.

Comments

Popular posts from this blog

AntiPattern: freezing a UI with Broadcast Receiver

How to centralize the support libraries dependencies in gradle

NotificationListenerService and kitkat