From API8, you can install your application on external storage. This is an optional feature. You can declare the android: installLocation attribute in your application's manifest. If you do not declare this attribute, your application will be installed in internal storage and cannot be moved to external storage.
When you declare preferExternal, you require your application to be installed in external storage, but the system is not sure that your application must be installed in external storage. If the external storage is full, it will be stored in the built-in storage. You can also move your application between two buckets. If you declare auto, you indicate that your application can be installed in external storage, but you do not have a preference for installation location. The system determines where your application is installed based on some factors. You can also move your program between two buckets.
When your application is installed in External Storage:
1. When your external storage is attached to your device, your application operations are not affected.
2..apk files are stored in external storage, but all private user data, databases, optimized. dex files, and extracted local code are stored in built-in storage.
3. the installed container of your application uses a random key for encryption and can only be decrypted by the device where the application is installed. This ensures that only one identical application is available on an sdcard.
4. You can move your application to built-in storage through system settings.
Note: When you use usb to store files shared with your computer or uninstall the SD Card through system settings, applications running in external storage will be immediately killed.
Forward compatibility
Applications installed before API8 will be installed in built-in storage and will not be moved to external storage.
However, your application can be set to support lower than API8 :,
1. In Set android: instaillLocation to auto or perferExternal.
2. Do not modify minSDKVersion and ensure that your application code is compatible.
3. To compile your application, change your build target to API8 because the low android library does not know the instaillLocation attribute and does not compile your application.
Applications that do not need to be installed in External Storage
If you use usb storage to share files with your computer or uninstall the SD Card through system settings, applications running in external storage will be immediately killed.
To make your application run as expected, you cannot install your application on external storage if you use the features.
1. Service: the services you run will be killed and will not be restarted when external storage is mounted. But you can registerACTION_EXTERNAL_APPLICATIONS_AVAILABLE broadcast intent, so that when your external application becomes available, it will be reminded.
2. Alarm service: services registered with AlarmManager will be canceled. You must re-register them when external storage is remounted.
3. Input Method engine: Your IME will be replaced by the default IME.
4. Live Wallpaper: The wallpaper you run will be replaced by the default live wallpaper.
5. App widget: Your Appwidget will be removed from the desktop.
6. Account Management: accounts created using AccountManager will disappear.
7. synchronous Adapter: Your AbstractThreadedSyncAdapter and all its synchronization methods will not work.
8. receiver of the boot completed broadcast: the system will issue ACTION_BOOT_COMPLETED broadcast between the mounted external storage, and the application you install in the external storage will not be broadcast.
Applications that need to be installed in External Storage
Other applications can be installed in external storage. Large Games are usually installed in external storage because the game does not need to provide additional services when it is not active, when external storage is unavailable, the game will be killed. When external storage becomes available and the user restarts the game, there should be no visible impact (assuming that the game has properly saved its status in its normal Activity lifecycle)
When your application requires a MB apk file, you should carefully consider installing the application in external storage so that users can save the built-in storage space.