如何讓本身的Android應用程序支持安裝到SD卡呢?html
下面給出官方的解決方案android
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
- <manifest xmlns:android="http://schemas.android.com/apk/res/android"
- android:installLocation="preferExternal"
- ... >
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
.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.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