从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"
... >
【安装到外部存储中】
- 不会影响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.
根据你的App类型选择安装位置。理论上,所有App可以安全地安装到外部存储中
来源:http://developer.android.com/guide/topics/data/install-location.html#Compatiblity
分享到:
相关推荐
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="1" android:versionName="1.0.2" package="com.companyname.boshiac.forklift.app" android:installLocation="auto"> ...
android:scheme 通过uri跳转到APP应用指定Activity
installApp : 安装App(支持6.0) installAppSilent : 静默安装App uninstallApp : 卸载App uninstallAppSilent : 静默卸载App isAppRoot : 判断App是否有root权限 launchApp : 打开App getAppPackageName : 获取App...
由于配置了android:persistent="true"属性,并且Phone.apk是安装在/system/app/目录下的,所以在开机时会自动启动PhoneApp类
WIFI室内定位Android APP,包括定位APP和数据采集APP
Android模拟器安装APP出现INSTALL_FAILED_NO_MATCHING_ABIS错误解决方案 当我们想在电脑的Android模拟器中安装APP的时候,会报INSTALL_FAILED_NO_MATCHING_ABIS错误【如图1】,导致APP无法在模拟器中运行。下面给出...
Android在一个app中实现另一个app的自动安装,安装完成后自动打开(需Root),详细了解请移步:http://blog.csdn.net/zxc514257857/article/details/77485561
本科毕设:Android 平台上的计步算法及APP设计与实现 本科毕设:Android 平台上的计步算法及APP设计与实现 本科毕设:Android 平台上的计步算法及APP设计与实现 本科毕设:Android 平台上的计步算法及APP设计与实现 ...
已经装eclipse,android sdk及adt的安装和配置。 1.进入eclipse界面,新建android工程 new > android project 2.该工程目录下建立两个文档 /libs 和 /assets/www 3.把phonegap中android目录下的cordova-1.7.0.js...
点击浏览器中的URL链接,启动特定的App。 ...[scheme]://[host]/[path]?[query]">启动应用程序 ... <data android:scheme="myapp" android:host="jp.app" android:pathPrefix="/openwith"/> </intent-filter>
Android Studio开发实战:从零基础到App上线
把其它app 放在assets/ 下面打包, 通过系统调用安装这个app //申请安装未知应用权限 Uri packageURI = Uri.parse("package:" + mContext.getPackageName()); Intent intent = new Intent(Settings.ACTION_...
android:label="@string/app_name" android:supportsRtl="true" android:theme="@style/AppTheme"> <!--这里添加正确的key和value --> <meta-data android:name="com.baidu.lbsapi.API_KEY" android...
android APK install tool can install your APK will File to c://install_apks/you3_apk.apk can install P.S Android Phone will to "Debug mode" via ADB Tool Auto Install you APP
Android APP:开机自动启动app demo 源码 Android启动完成会发出一个系统广播 ACTION_BOOT_COMPLETED,字符串常量表示为 “android.intent.action.BOOT_COMPLETED”,我们要做的是用BroadcastReceiver接收这个消息...
Android实战内容:TestApp
Android获取手机APP安装列表,系统和非系统APP
一个app启动另一个app,这个玩法挺火的嘛,有没有试过更新QQ到5.1版本,QQ的健康里面就可以添加其他app,实现从QQ跳转到其他app应用,这里模拟写了一个demo
uiautomatorviewer 添加xpath属性,三种方法 ...uiseletor:new UiSelector().className(\"android.widget.Button\").textContains(\"下载安装\").resourceId(\"com.android.huayi:id/btn_download_update_dialog\")
Android Studio项目《天气预报app》