从Level8(版本2.2)开始,可以将App安装到外部存储器(如SD卡)。通过在manifest属性中声明android:installLocation实现该功能,如果不声明,应用只会安装到内部存储器,并且不能转移到外部存储中。
在AndroidManifest.xml中加上属性android:installLocation,设置为preferExternal或auto
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
android:installLocation="preferExternal"
... >
【安装到外部存储中】
[list]
[*]不会影响App性能;
[*].apk文件保存在外部存储中,而用户私有数据、数据库等保存在内部存储中;
[*]由于存储App的容器由手机唯一加密,所以SD卡上的所有应用只能在本手机上解密使用。
[/list]
【注意】
当手机开启USB大容量存储(USB mass storage)与电脑连接共享文件,或通过系统设置卸载SD卡后,所有外部存储中的应用都无法运行使用。
当App存在以下特性时,不要安装到外部存储中
[b]Services[/b]
Your running Service will be killed and will not be restarted when external storage is remounted. You can, however, register for the ACTION_EXTERNAL_APPLICATIONS_AVAILABLE broadcast Intent, which will notify your application when applications installed on external storage have become available to the system again. At which time, you can restart your Service.
[b]Alarm Services[/b]
Your alarms registered with AlarmManager will be cancelled. You must manually re-register any alarms when external storage is remounted.
[b]Input Method Engines[/b]
Your IME will be replaced by the default IME. When external storage is remounted, the user can open system settings to enable your IME again.
[b]Live Wallpapers[/b]
Your running Live Wallpaper will be replaced by the default Live Wallpaper. When external storage is remounted, the user can select your Live Wallpaper again.
[b]App Widgets[/b]
Your App Widget will be removed from the home screen. When external storage is remounted, your App Widget will not be available for the user to select until the system resets the home application (usually not until a system reboot).
[b]Account Managers[/b]
Your accounts created with AccountManager will disappear until external storage is remounted.
[b]Sync Adapters[/b]
Your AbstractThreadedSyncAdapter and all its sync functionality will not work until external storage is remounted.
[b]Device Administrators[/b]
Your DeviceAdminReceiver and all its admin capabilities will be disabled, which can have unforeseeable consequences for the device functionality, which may persist after external storage is remounted.
[b]Broadcast Receivers listening for "boot completed"[/b]
The system delivers the ACTION_BOOT_COMPLETED broadcast before the external storage is mounted to the device. If your application is installed on the external storage, it can never receive this broadcast.
根据你的App类型选择安装位置。理论上,所有App可以安全地安装到外部存储中
来源:http://developer.android.com/guide/topics/data/install-location.html#Compatiblity
在AndroidManifest.xml中加上属性android:installLocation,设置为preferExternal或auto
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
android:installLocation="preferExternal"
... >
【安装到外部存储中】
[list]
[*]不会影响App性能;
[*].apk文件保存在外部存储中,而用户私有数据、数据库等保存在内部存储中;
[*]由于存储App的容器由手机唯一加密,所以SD卡上的所有应用只能在本手机上解密使用。
[/list]
【注意】
当手机开启USB大容量存储(USB mass storage)与电脑连接共享文件,或通过系统设置卸载SD卡后,所有外部存储中的应用都无法运行使用。
当App存在以下特性时,不要安装到外部存储中
[b]Services[/b]
Your running Service will be killed and will not be restarted when external storage is remounted. You can, however, register for the ACTION_EXTERNAL_APPLICATIONS_AVAILABLE broadcast Intent, which will notify your application when applications installed on external storage have become available to the system again. At which time, you can restart your Service.
[b]Alarm Services[/b]
Your alarms registered with AlarmManager will be cancelled. You must manually re-register any alarms when external storage is remounted.
[b]Input Method Engines[/b]
Your IME will be replaced by the default IME. When external storage is remounted, the user can open system settings to enable your IME again.
[b]Live Wallpapers[/b]
Your running Live Wallpaper will be replaced by the default Live Wallpaper. When external storage is remounted, the user can select your Live Wallpaper again.
[b]App Widgets[/b]
Your App Widget will be removed from the home screen. When external storage is remounted, your App Widget will not be available for the user to select until the system resets the home application (usually not until a system reboot).
[b]Account Managers[/b]
Your accounts created with AccountManager will disappear until external storage is remounted.
[b]Sync Adapters[/b]
Your AbstractThreadedSyncAdapter and all its sync functionality will not work until external storage is remounted.
[b]Device Administrators[/b]
Your DeviceAdminReceiver and all its admin capabilities will be disabled, which can have unforeseeable consequences for the device functionality, which may persist after external storage is remounted.
[b]Broadcast Receivers listening for "boot completed"[/b]
The system delivers the ACTION_BOOT_COMPLETED broadcast before the external storage is mounted to the device. If your application is installed on the external storage, it can never receive this broadcast.
根据你的App类型选择安装位置。理论上,所有App可以安全地安装到外部存储中
来源:http://developer.android.com/guide/topics/data/install-location.html#Compatiblity