Before Android 2.1 Program It can only be installed in the body memory (RAM). This feature prevents Android development from some point of view, because Ram has limited space, therefore, this feature limits the size of the application and the functionality of the application.
Since Android 2.2, the android system has introduced an all-new feature, app2sd, which allows the Android system to allow applications to be installed on the SD card, while saving more RAM space, on the other hand, applications are allowed to expand their size.
However, the android system only supports app2sd, which is not enough. If the application is not processed, it will continue to be transferred to ram. This is because the Android system is backward compatible. What if I want my application to load an SD card instead of Ram? This requires the android configuration file of the application.Manifest. xml Manifest ElementAdd inAndroid: installlocation attributes. The value is perferextenal or auto.
Perferextental -- it means that this application is installed to extended storage (usually the SD card), but the system cannot ensure that the application will certainly be installed to extended storage. If the extended storage has no space or is unavailable, the system will still install the application in Ram.
Auto -- it means that this application may be installed to the extended storage, but there is no special preference for the installation location, there will be systems based on their ownAlgorithmTo determine where to install the application. Http://www.my400800.cn)
Internalonly -- meaning that this application can only be installed in Ram.
Once Android: installlocation is added, You can freely move the application between RAM and the SD card regardless of the value. After the application is installed on the SD card, pay attention to the following points:
1. Only APK files are saved on the SD card. Private data, databases, optimized Dex files and released native files of all other usersCodeStill saved on Ram.
2. the applications on the SD card are encrypted during installation. Therefore, the applications installed on the SD card only work on the devices where the application is installed and cannot run on other devices.
3. When you Enable USB high-capacity storage to share files with your computer or uninstall the SD card, all applications installed on the SD card will be immediately terminated.
Because the application installed on the SD card will be affected by the SD card status, to ensure the robustness of the application, when determining whether the application can be installed on the SD card, the following principles should be implemented:
1. Applications with backend services should not support app2sd. Because the service is invisible to the front-end interface, you cannot know whether the service of the application is active when you detach the SD card or Enable USB. Therefore, the Service may be terminated unexpectedly.
2. The input method program should not support app2sd. If SD is uninstalled or USB is enabled, the input method is terminated and replaced by the default input method.
3. Applications that normally display the UI, such as wallpapers and widgets, should not support app2sd.
4. Applications related to user data, such as accountmanager, should not support app2sd because users created through accountmanager cannot be seen before the SD card is mounted normally.
If the application has services, or supports desktop gadgets, do not install the software on the SD card. An insurance method is to specify the value of Android: installlocation as internalonly.
Because app2sd is a new feature of Android 2.2, if the application is planned to support versions earlier than Android 2.2 for backward compatibility, perform the following steps:
1. Add the Android: installlocation attribute to the manifest element and specify its value as perferexternal or auto.
2. specify the value of andorid: minsdkversion. The value can be smaller than 8 (Before Version 2.2 ).
3. Change the build target of the application to API Level 8 so that the compiler can compile the application. (Required) If no build target is specified, the old Android library cannot understand the Android: installlocation attribute and thus cannot compile the application.
After the preceding three steps are implemented, if the application is installed on a device with an API level lower than 8, the Android: installlocation attribute is ignored. The application is installed on Ram.