android:installLocation这个属性

从Level8(版本2.2)开始,可以将App安装到外部存储器(如SD卡)。通过在manifest属性中声明android:installLocation实现该功能,如果不声明,应用只会安装到内部存储器,并且不能转移到外部存储中。

在AndroidManifest.xml中加上属性android:installLocation,设置为preferExternal或auto

android:installLocation="preferExternal"

... >

【安装到外部存储中】

不会影响App性能;

.apk文件保存在外部存储中,而用户私有数据、数据库等保存在内部存储中;

由于存储App的容器由手机唯一加密,所以SD卡上的所有应用只能在本手机上解密使用。

【注意】

当手机开启USB大容量存储(USB mass storage)与电脑连接共享文件,或通过系统设置卸载SD卡后,所有外部存储中的应用都无法运行使用。

当App存在以下特性时,不要安装到外部存储中

Services

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.

Alarm Services

Your alarms registered with AlarmManager will be cancelled. You must manually re-register any alarms when external storage is remounted.

Input Method Engines

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.

Live Wallpapers

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.

App Widgets

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).

Account Managers

Your accounts created with AccountManager will disappear until external storage is remounted.

Sync Adapters

Your AbstractThreadedSyncAdapter and all its sync functionality will not work until external storage is remounted.

Device Administrators

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.

Broadcast Receivers listening for "boot completed"

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


文章来自 作者 http://xin3336019-sina-com.iteye.com/blog/1845766

你可能感兴趣的:(android:installLocation这个属性)