How to Allow Your AIR for Android Application to be Moved to the SD Card

If you want users to be able to move your AIR for Android application to the SD card, all you have to do is modify the android manifest section of your application descriptor. If you want your application to be installed on internal storage by default, but allow users to move it to the SD card, set android:installLocation to "auto" like this:

<android>
    <manifestAdditions>
        <![CDATA[
            <manifest android:installLocation="auto">
                <uses-permission android:name="android.permission.INTERNET"/>
            </manifest>
        ]]>
    </manifestAdditions>
</android>

If you want your application to be installed on external storage by default (which the user can override), set the android:installLocation to "preferExternal" like this:

<android>
    <manifestAdditions>
        <![CDATA[
            <manifest android:installLocation="preferExternal">
                <uses-permission android:name="android.permission.INTERNET"/>
            </manifest>
        ]]>
    </manifestAdditions>
</android>

And finally, if you don’t want to give users an option of where to install your application (not sure why you’d do this, but you can), just leave the android:installLocation attribute out entirely.

For more details, see the App Install Location section of the Android docs.

13 Responses to How to Allow Your AIR for Android Application to be Moved to the SD Card

  1. MichaelJW says:

    What disadvantages are there to allowing users to install apps on their SD card? I have quite a few non-AIR apps installed which can’t be moved, so I’m curious.

  2. MichaelJW says:

    I sort of answered my own question. When apps are on the SD card, they can’t be used if the phone is plugged into a computer as a USB drive. In a lot of cases that’s not a problem, but it could be irritating for, say, a Twitter client.

    Still curious if there are any other reasons, though — particularly AIR-specific reasons.

  3. Christian Cantrell says:

    @MichaelJW: I think you picked up on the major issue. Otherwise, I don’t really see why you wouldn’t want people to be able to move your app to an SD card. I think it’s probably best to give the user the option.

  4. MichaelJW says:

    Thanks, Christian!

  5. Mike Rankin says:

    This does not seem to work on my Evo using burrito.

  6. Scoch says:

    Thanks for the tip, but this does not work for me…
    If it can help, I had to insert the manifest tags like this :

    <![CDATA[
    ]]>

  7. Scoch says:

    Sorry xml tags have not been accepted by in my initial comment…
    here is the xml code, just change () to regular tags

    (android)
    (manifestAdditions)
    (manifest)
    (attribute name=”android:installLocation” value=”auto”/ )
    (data)
    <![CDATA[
    ]]>
    (/data)
    (/manifest)
    (/manifestAdditions)
    (/android)

  8. angry says:

    Christian, have you tried it???
    It doesn’t work from Flash CS5…
    What exactly have I to do in order to put my application on external sd?
    Please make an example that works!
    I tried the Scoch’s one but it doesn’t work… every time I open the Air Android settings it rewrites the tag “manifest” removing android:installLocation=”preferExternal” (or “auto”)
    Thanks

  9. Scoch says:

    Angry,
    it worked but does not anymore since sdk changes…
    We have to look at http://developer.android.com/guide/appendix/install-location.html to insert properly our attribute.
    It works with the xml code below.
    But you are right, everytime we click OK in Air Android settings it rewrites all the xml…
    So we have to add this attribute just before to publish, when all the settings are definitive. It’s not very friendly but that’s the way it works.

    (android)
    (manifestAdditions)
    (![CDATA[
    (manifest xmlns:android=”http://schemas.android.com/apk/res/android” android:installLocation=”preferExternal”)
    (uses-permission android:name=”android.permission.INTERNET”/)
    (/manifest)
    ]])
    (/manifestAdditions)
    (/android)

  10. Eddie says:

    From Flash CS5 the xml file seems to be overwritten when I press publish so cannot set the installLocation at all….

  11. eddie says:

    Seemed to have it working now via the command line though not tried putting it live yet.
    http://flasheddierocks.com/blog/index.php/2011/04/compiling-a-flash-cs5-app-from-the-command-line/

  12. Scoch says:

    Flash CS5.5 has the same kind of bug with iOS application descriptor file.

    Adobe has published a tech-note that covers this issue:
    Error “Unexpected element/attribute” | Publish iOS application | Flash Professional CS5.5
    http://kb2.adobe.com/cps/909/cpsid_90916.html

    The solution is not super friendly but simple. Works also with Air 2.7.

  13. OMA says:

    For those that are having their XML files overwritten by Flash, just tick the checkbox “Manually manage permissions and manifest additions in the application descriptor file” (in the “Permissions” tab of the “AIR for Android Settings” window). That way it won’t overwrite that part of the XML again, but next time you have to add or remove permissions you’ll have to do it by hand in the XML file, not by ticking boxes in that window.