android 支持 安装到 SD卡
如何让自己的Android应用程序支持安装到SD卡呢?
下面给出官方的解决方案
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
- Backward Compatibility
- Applications That Should NOT Install on External Storage
- Applications That Should Install on External Storage
See also
<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.
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:
- <manifestxmlns: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.
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.
When your application is installed on the external storage:
- 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.
更多相关文章
- Android开发错误——Android Studio中遇到过的错误问题与解决方
- 最新版 Android SDK 无法获取SDK包 的解决方案
- 最全的PHP开发Android应用程序
- 用Eclipse开发Android应用程序(3): 开发第一个Android应用程序He
- android中怎样将自己的应用程序的签名改为系统签名一样
- 使用PHP开发Android应用程序技术介绍
- Android处理屏幕旋转时的解决方案