android 支持 安裝到 SD卡

 如何讓本身的Android應用程序支持安裝到SD卡呢?html

下面給出官方的解決方案android

App Install Location

Quickview

  • You can allow your application to install on the device's external storage.
  • Some types of applications should not allow installation on the external storage.
  • Installing on the external storage is ideal for large applications that are not tightly integrated with the system (most commonly, games).

In this document

  1. Backward Compatibility
  2. Applications That Should NOT Install on External Storage
  3. Applications That Should Install on External Storage

See also

  1. <manifest>

Beginning with API Level 8, you can allow your application to be installed on the external storage (for example, the device's SD card). This is an optional feature you can declare for your application with the android:installLocation manifest attribute. If you do not declare this attribute, your application will be installed on the internal storage only and it cannot be moved to the external storage.app

To allow the system to install your application on the external storage, modify your manifest file to include the android:installLocation attribute in the <manifest> element, with a value of either "preferExternal" or "auto". For example:dom

 

  
  
  
  
  1. <manifest xmlns:android="http://schemas.android.com/apk/res/android" 
  2.     android:installLocation="preferExternal" 
  3.     ... > 

If you declare "preferExternal", you request that your application be installed on the external storage, but the system does not guarantee that your application will be installed on the external storage. If the external storage is full, the system will install it on the internal storage. The user can also move your application between the two locations.ide

If you declare "auto", you indicate that your application may be installed on the external storage, but you don't have a preference of install location. The system will decide where to install your application based on several factors. The user can also move your application between the two locations.ui

When your application is installed on the external storage:this

  • There is no effect on the application performance so long as the external storage is mounted on the device.
  • The .apk file is saved on the external storage, but all private user data, databases, optimized .dex files, and extracted native code are saved on the internal device memory.
  • The unique container in which your application is stored is encrypted with a randomly generated key that can be decrypted only by the device that originally installed it. Thus, an application installed on an SD card works for only one device.
  • The user can move your application to the internal storage through the system settings.

Warning: When the user enables USB mass storage to share files with a computer or unmounts the SD card via the system settings, the external storage is unmounted from the device and all applications running on the external storage are immediately killed.idea

相關文章
相關標籤/搜索