How can i enable my app to be moved to the sdcard?
You have to set android:installLocation
entry in AndroidManifest.xml file (preferExternal
or auto
values will do).
NB! For this build target should be API Level 8 (Android 2.2).
You can also set the android:installLocation
and still target to Android 1.6.
In your AndroidManifest.xml
you have to insert the min SDK Version like that
<uses-sdk android:minSdkVersion="4" />
This will make sure your application works only on Android 1.6 and higher. This will of course, cause an compiler error in your Eclipse project sapce. That's because the 1.6 SDK don't know about the android:installLocation
. To fix this, right-click on your Project in the Eclipse Project space (assuming you're using Eclipse, don't know how it works in other IDEs or with Ant build) then go to the "Android" Option and select "Project Build Target" to Android 2.2
.
This will remove the error shown above and you can compiler/export your APK file. This way the APK will work on Android 1.6-2.1 as usual and on Android 2.2 it will enable you to use SD card to install/move the app too.
However a Word of Warning: This can be a source of incompatibility, if you're not careful. So an increased testing phase is required, because you won't notice directly if you use an 2.x feature, because Eclipse wont show it as error, because it uses the Android 2.2 SDK as reference.
So you basically have 2 choices: 1. Only do the steps above when you're exporting/signing your app (i.e. just before you're about to publish this new version) and then set it back or 2. Extensively test your Applications on 1.6 Device or Emulator and see if it crashes at any point, because the App uses a feature only available on newer OS' than 1.6.
Depending on the compexity of your application, the first one is usually the safer one, however bears the risk that you forgot to do it once. This would have the consequence that for this one update the user won't have the possibility to install it on SD card. Choice 2 has the problem, that if you don't test everything well enough, you App may suddenly ForceClose when an Android 1.6 devices try to call features/functions only available in 2.x.