Tuesday, August 16, 2011

How To Move Applications to SDCARD in Android

From Android 2.2 Froyo onwards we can allow the application has to be installed on the external storage(SDCARD)

This feature is enabled by using this tag android:installLocation. By declaring this permission in the android manifast file.

If we do not declare this attribute, the application will be installed on the internal storage only and it cannot be moved to the external storage.

To allow the system to install your application on the external storage, modify the manifest file to include the android:installLocation attribute in the <manifest> element, with a value of either "preferExternal" or "auto". For example:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    android:installLocation="preferExternal" or android:installLocation="auto"
    ... >

preferExternal : The App installs on the sdcard.

auto : There is no preference. The system will decide where to install based on several Factors.

However,  if your application is designed to support an API Level lower than 8, you can choose to support this feature for devices with API Level 8 or greater and still be compatible with devices using an API Level lower than 8.

To allow installation on external storage and remain compatible with versions lower than API Level 8:
  • Include the android:installLocation attribute with a value of "auto" or   "preferExternal" in the <manifest> element.
  • Leave your android:minSdkVersion attribute as is (something less than "8") and be certain that your application code uses only APIs compatible with that.
  • In order to compile your application, change your build target to API Level 8 (In default.properties). This is necessary because older Android libraries don't understand the android:installLocation attribute and will not compile your application when it's present.

Note: For More Information http://developer.android.com/guide/appendix/install-location.html

No comments:

Post a Comment