Setting this property allows developers and users to determine where the program will be installed.
The android:installlocation belongs to the manifest node in Androidmanifest.xml. As shown below:
The default install location for the application.
The following keyword strings is accepted:
| Value |
Description |
"internalOnly" |
The application must is installed on the internal device storage only. If This is set, the application would never be installed on the external storage. If the internal storage is full and then the system would not install the application. This is also the default behavior if your do not define android:installLocation . |
"auto" |
The application is installed on the external storage, but the system would install the application on the internal stor Age by default. If the internal storage is full and then the system would install it on the external storage. Once installed, the user can move the application to either internal or external storage through the system settings. |
"preferExternal" |
The application prefers to is installed on the external storage (SD card). There is no guarantee that the system would honor this request. The application might be installed on internal storage if the external media are unavailable or full, or if the application Uses the forward-locking mechanism (not supported on external storage). Once installed, the user can move the application to either internal or external storage through the system settings. |
Android:installlocation can be set to any of the three values of "auto", "internalonly", "preferexternal".
Auto: The program may be installed on external storage media (e.g. SD Card), but it will be installed to the phone memory by default. When the phone memory is empty, the program will be installed to external storage media. When the program is installed on the phone, the user can decide whether to place the program in an external storage medium or in memory.
internalonly: Default value. When set to this value, the program can only be installed in memory, and if the memory is empty, the program will not install successfully.
preferexternal: The program is installed on an external storage medium, but the system does not guarantee that the program will be installed on the external storage media. When external storage media is not available or empty, The program will be installed in memory. The program will also be installed in memory when the forward-locking mechanism is used, because external storage does not support this mechanism. After the program is installed, the user can freely switch whether the program should be on the external or internal storage media.
Note: When the program uses the Copy protection feature of Google Play, it can only be installed in memory.
When the program is installed on an external storage medium,
The ① . apk file will be moved to the external storage media, but the program's data will still be in memory
② the container where the. apk file is saved will be encrypted with a randomly generated key, so that only the settings for that program can use the data that exists on the external storage media.
Warning: When external storage media is uninstalled, programs installed on that external storage media will be terminated immediately!
Backward compatibility:
Android:installlocation is declared, but Android:minsdkversion is less than 8 o'clock, we compile with an AVD of no less than froyo, so that in less than Froyo The android:installlocation in the system will be ignored, and the android:installlocation we specify is used in systems not less than Froyo.
Suggestions:
We should not install the program on external storage media when the program has the following behavior
①service
The running service will be terminated and the service will not be restarted when the external storage media is reloaded.
②alarm Service
The alarm service will be canceled and the developer must re-register the alarm service after the external storage media is reloaded.
③input Method Engines
Input method will be replaced by the system input method, when the external storage media is reloaded, the user can use the system settings to start our input method
④live Wallpapers
Our live wallpaper will be replaced with the default live wallpaper. After the external storage media is overloaded, the user can change back.
⑤live Folders
Our dynamic folder will be moved out.
⑥app Widgets
Our widgets will be moved out, and our widgets are usually available only after the system restarts.
⑦account Managers
Accounts created with Accountmanager will disappear until the storage media is reloaded.
⑧sync Adapters
Our sync feature is only available when external storage media is reloaded
⑨device Administrators
Our deviceadminreceiver will be void.
⑩ Monitoring Boot End Event
Action_boot_completed broadcasts are sent before the external storage media is loaded. Therefore, programs installed on external storage media will not be able to accept power-on broadcasts.
In general, we can install programs on external storage media as long as we do not use the above features. For example, a large game program. When the APK file is large we should seriously consider whether to move the program to external storage media to help users save memory.