Thursday, November 4, 2010

Application Install to SD Card

As many of you know, a great feature included with Android 2.2 is the ability to install apps to the SD card.  Most Android phones have a limited amount of ROM, which is used for system files, text messages, emails, applications, etc.  All applications that do not implement services, Fortunately, this is an extremely easy feature to implement in an application, and it done while being compatible with previous versions of Android.

In the manifest tag of the Android Manifest, simply add the attribute
to the Manifest tag.  Now, in order for this to compile you must use the Android 2.2 SDK.  In order to ensure backwards compatibility, make sure to set your minimum SDK requirement to whichever SDK the rest of your application will work for.  When the application is loaded on an older version of Android than Froyo, this tag will simply be overlooked.

Now, some may be hesitant to constantly compile their application against a newer version because they may accidentally overlook the use of a newer API that may crash the application at runtime.  This can be circumvented by loading all your class and resource files into a separate library project which compiles against the older SDK and importing it into your main project.  In your main project, all that is needed is a manifest.

If you already have Android library files, this should not be an issue as with the recent SDK tools (r7), Android libraries may now import Android library themselves.

No comments:

Post a Comment