(转)Android如何编程设置APP安装位置(外部存储或内部存储)?
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 theandroid:installLocation attribute in the <manifest> element, with a value of either "preferExternal" or "auto". For example:
<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.
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
.apkfile is saved on the external storage, but all private user data, databases, optimized.dexfiles, 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.
拣重点说一下这篇文章。这篇技术文档主要核心内容是讲,从Android API Level 8开始,Android APP开发者可以在自己的APP中编程设置APP安装的位置:安装在外置/外部扩展存储卡上(比如设备上用户插入的扩展SD卡)。这一特色的实现,只需在Android的manifest设置:android:installLocation 的属性值。如果开发者没有设置这一值,那么,Android系统将会把你的APP安装在内置/内部存储中并且不允许被移动到外部/外置存储。
因此,为了能让系统把你的APP安装在外部/外置扩展存储中,你需要在manifest修改android:installLocation 的属性值,把android:installLocation 设置为"preferExternal" o或者"auto"。
如果你声明了"preferExternal"(android:installLocation= "preferExternal",),意即为要求系统将你的APP安装在外部/外置扩展存储,但是系统并一定总是这么做。假设外部/外置存储已满,系统仍然会将你的APP安装在内部/内置存储。当用户安装了你的APP后,用户可以把你的APP在外部/外置和内部/内置存储之间来回移动。
如果你声明了 "auto"(android:installLocation ="auto"),你意图让系统把你的APP安装在外部/外置存储,但是你没有对安装位置有特别偏好。所以最终还是由系统综合考量若干因素然后决定你的APP安装的位置,同时,用户仍然可以自主的在外部和内部存储之间来回移动你的APP。
更多其他详细细节内容,请看原始谷歌官方文档,文档链接地址:http://developer.android.com/guide/topics/data/install-location.html#Compatiblity
本文转载与于:http://blog.csdn.net/zhangphil/article/details/46534175
(转)Android如何编程设置APP安装位置(外部存储或内部存储)?的更多相关文章
- Android内存解析(二)— 详解内存,内部存储和外部存储
总述 觉得十分有必要搞清楚内存,内部存储和外部存储的区别,还有我们在开发中真正将数据存在了手机的哪儿. 先提一个问题:手机设置的应用管理中,每个App下都有清除数据和清除缓存,清除的分别是哪里的数据? ...
- android数据储存之应用安装位置
原文地址:http://developer.android.com/guide/topics/data/install-location.html#Compatiblity 从API8開始,你能够将你 ...
- app安装位置声明
AndroidManifest.xml <manifest xmlns:android="http://schemas.android.com/apk/res/android" ...
- Android数据存储之内部存储、外部存储
首先来介绍下什么是内部存储? 在Android平台下,有着自己独立的数据存储规则,在windows平台下,应用程序能够自由的或者在特定的訪问权限基础上訪问或改动其它应用程序下的文件资源. 可是在And ...
- [Android教程]EditText设置/隐藏光标位置、选中文本和获取/清除焦点
有时候需要让光标显示在EditText的指定位置或者选中某些文本.同样,为了方便用户输入以提升用户体验,可能需要使EditText获得或失去焦点. 1. 设置光标到指定位置 EditText et ...
- Android数据存储-读取内部存储空间数据
内部存储空间的默认位置 data/data/应用名称 写数据,获取FileOutPutStream的方式 1.直接写死路径的方式 FileOutputStream fos = new FileOutp ...
- 初探Lambda表达式/Java多核编程【0】从外部迭代到内部迭代
开篇 放假前从学校图书馆中借来一本书,Oracle官方的<精通Lambda表达式:Java多核编程>. 假期已过大半才想起来还没翻上几页,在此先推荐给大家. 此书内容及其简洁干练,如果你对 ...
- Android应用程序的安装位置
Android应用程序的默认安装位置以及是否可移动取决于开发者在其AndroidManifest.xml中的设置: <manifestxmlns:android="http://s ...
- Android中的内存储、外存储概念、文件操作与PC端的有些不同
其实安卓文件的操作和java在pc环境下的操作并无二致,之所以需要单独讲解是因为安卓系统提供了不同于pc的访问文件系统根路径的api,同时对一个应用的私有文件做了统一的管理.初学者在这部分感到很容易混 ...
随机推荐
- 新浪SAE使用Thinkphp框架,禁用memcache节省豆子的方法
请在入口文件定义常量,SAE_RUNTIME为true请在本地打开命令行, cd 到项目所在文件夹,执行命令: php index.php 此时会在./App/Sae_Runtime目录下批量生成缓存 ...
- POJ 2516 Minimum Cost [最小费用最大流]
题意略: 思路: 这题比较坑的地方是把每种货物单独建图分开算就ok了. #include<stdio.h> #include<queue> #define MAXN 500 # ...
- MongoDB增删改查
MongoDB以文档的形式存储数据,文档是类似于JSON键值对结构的BSON格式. 许多有共性的文档就组成一个集合. 集合.文档分别对应关系型数据库的表和行记录. 进入数据库: [mongodb@lo ...
- HtmlPrefixScopeExtensions
http://blog.stevensanderson.com/2010/01/28/editing-a-variable-length-list-aspnet-mvc-2-style/
- struts2+hibernate+poi导出Excel实例
本实例通过struts2+hibernate+poi实现导出数据导入到Excel的功能 用到的jar包: poi 下载地址:http://poi.apache.org/ 根据查询条件的选择显示相应数据 ...
- TestCase--网站注册模块
对于web测试,注册模块是必测的一个点,所以今天就来总结一下注册模块的测试用例 参考京东的注册页面 测试用例设计如下: 一.功能测试 1. 单击“免费注册”,页面是否正常跳转 2. 直接访问注册页 ...
- 关于NopCommerce3.6版用户登录详解
一.登录方式 Nop登录方式有两种(且只能选择一种方式登录):一种是用用户名登录,另一种是用户注册邮箱登录,这个在后台可配置: 第一种:用户名登录 后台配置路径在商城设置à设置管理à客户设置:使用用户 ...
- 3.5 The Lexical-Analyzer Generator Lex
3.5 The Lexical-Analyzer Generator Lex In this section, we introduce a tool called Lex, or in a more ...
- 【测试】RAC搭建(裸设备)
环境描述: 节点一 节点二 主机名 rac1 rac2 IP 192.168.10.11 192.168.10.12 IP-VIP 192.168.10.111 192.168.10.112 IP ...
- 在代码中调用 mvc 4 api
mvc 4 api 的调用有很多种,最常见也最简单的一种是 用 ajax 的方式在前端界面中调用, 如果是在后台代码中调用 ,是要复杂一些,以下是 以 post 的方式调用 api 的封装好的方法: ...