Saturday 10 November 2012

Enabling the "Move to SD card" option on your android apps


Here's a quick and easy tip that your android app users will love, especially those with older/cheaper devices that don't have a huge amount of internal memory!

Take your existing android application, and add android:installLocation="auto" to the manifest tag in AndroidManifest.xml.

Example:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
   package="com.mrdt.zombiesurvivalgame"
   android:versionCode="2"
   android:versionName="1.0.1"
   android:installLocation="auto">


  • Setting installLocation to "auto" means the user can choose where to install the application.
  • Setting installLocation to "internalOnly" means the app will install on internal memory only (not ideal in most cases, especially if your app is quite big).
  • Setting installLocation to "preferExternal" means the app will automatically try to install itself of the SD card if it is present and is not full.


You'll also need to ensure that your build target (targetSdkVersion in uses-sdk tag in AndroidManifest.xml) is set to API Level 8 or greater.

Example:
<uses-sdk android:minSdkVersion="5" android:targetSdkVersion="15" />

Save your updated AndroidManifest.xml file, rebuild your app, and deploy to a device or virtual device running Android 2.2 or above. Now if you open Settings > Applications, and select your app, you should be offered the option to "Move to SD card" :)

I've just updated my android games to offer users this option, and it'll be something I'll be doing as standard in all my future apps. If you're an app developer you should consider doing the same... As a user I appreciate being given the option to choose where to install my apps - and I'm sure others do too!


No comments:

Post a Comment