首页 > 代码库 > 【移动开发】android:installLocation

【移动开发】android:installLocation

android:installLocation
The default install location for the application.

The following keyword strings are accepted:

ValueDescription
"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 define android: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. Once installed, the user can move the application to either internal or external storage through the system settings.

Note: By default, your application will be installed on the internal storage and cannot be installed on the external storage unless you define this attribute to be either "auto" or "preferExternal".

When an application is installed on the external storage:

  • The .apk file is saved to the external storage, but any application data (such as databases) is still saved on the internal device memory.
  • The container in which the .apk file is saved is encrypted with a key that allows the application to operate only on the device that installed it. (A user cannot transfer the SD card to another device and use applications installed on the card.) Though, multiple SD cards can be used with the same device.
  • At the user‘s request, the application can be moved to the internal storage.

The user may also request to move an application from the internal storage to the external storage. However, the system will not allow the user to move the application to external storage if this attribute is set to internalOnly, which is the default setting.

Read App Install Location for more information about using this attribute (including how to maintain backward compatibility).

Introduced in: API Level 8.

【移动开发】android:installLocation