By setting this attribute, developers and users can determine the installation location of the program.
Android: installLocation belongs to the manifest node in AndroidManifest. XML as follows:
The default install location for the application.
The following keyword strings are accepted:
| Value |
Description |
"internalOnly" |
The application must be installed on the internal device storage only. if this is set, the application will never be installed on the external storage. if the internal storage is full, then the system will not install the application. this is also the default behavior if you do not defineandroid:installLocation. |
"auto" |
The application may be installed on the external storage, but the system will install the application on the internal storage by default. if the internal storage is full, then the system will 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 be installed on the external storage (SD card ). there is no guarantee that the system will honor this request. the application might be installed on internal storage if the external media is 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 "auto", "internalOnly", and "preferExternal" values.
Auto: The program may be installed on external storage media (for example, SD Card), but it will be installed in the phone memory by default. when the phone memory is empty, the program will be installed on the external storage media. after the program is installed on the mobile phone, you can decide whether to store the program in the external storage media or memory.
InternalOnly: Default value. When this value is set, the program can only be installed in the memory. If the memory is empty, the program cannot be successfully installed.
PreferExternal: Install the program on the external storage media, but the system does not guarantee that the program will be installed on the external storage media. when the external storage media cannot or is empty, the program will be installed in the memory. when the program uses the forward-locking mechanism, it will also be installed into the memory, because external storage does not support this mechanism. after the program is installed, You can freely switch the program on the external or internal storage media.
Note: The Copy Protection feature of Google Play can only be installed in the memory.
When a program is installed on an external storage medium,
①The. apk file will be moved to the external storage medium, but the program data will still be in the memory
②The container storing the .apk file will use a randomly generated key for encryption, so that only the settings for installing the program can use data stored on the external storage media.
Warning when the external storage media is uninstalled, the program installed on the external storage media will be immediately terminated!
Backward compatibility:
When android: installLocation is declared, but android: minSdkVersion is less than 8, we use AVD not lower than Froyo for compilation. In this way, android: installLocation will be ignored in systems lower than Froyo, the android: installLocation specified by us will be used in systems not lower than Froyo.
Suggestion:
When the program performs the following actions, we should not install the program on the external storage media.
① Service
The running service will be terminated. When the external storage media is reloaded, the service will not be restarted.
② Alarm Service
The alarm service will be canceled. Developers must re-register the alarm service after the external storage media is reloaded.
③ Input Method Engines
The input method will be replaced with the system input method. After the external storage media is reloaded, you can start our input method through system settings.
④ Live Wallpapers
Our live wallpaper will be replaced with the default live wallpaper. After the external storage medium is reloaded, you can change it back.
⑤ Live Folders
Our dynamic folder will be removed.
⑥ App Widgets
Our widgets will be removed. Normally, our widgets are available only after the system is restarted.
7account Managers
Accounts created using AccountManager will disappear until the storage media is reloaded.
⑧ Sync Adapters
Our synchronization function is available only when the external storage media is reloaded.
Administrative Device Administrators
Our DeviceAdminReceiver will be invalid.
Listen to boot end events
The system will send ACTION_BOOT_COMPLETED broadcast before loading the external storage media. Therefore, programs installed in the external storage media cannot accept the boot broadcast.
Generally, as long as we do not use the above features, we can install the program on the external storage media. 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.