(转)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,同时对一个应用的私有文件做了统一的管理.初学者在这部分感到很容易混 ...
随机推荐
- HYSBZ 1061 志愿者招募 【最小费用流】【差分】【最小费用流模板】
#include<stdio.h> #include<queue> #define MAXN 1003 #define MAXM 10002*4 #define INF 100 ...
- Selenium 疑问之二:如何使页面滚动条移动到指定元素element的位置处?
在用selenium做测试时,会遇到需要操作的元素不在当前可视页面中的情况,如果是手工测试,自然很简单,手动拖拽滚动条到目标元素处即可. 那么,selenium如何实现这种情形呢?答案是需要借助Jav ...
- python编写接口
- maven多工程构建与打包
目标:webapp_aggregator为聚合和父pom工程,不包含代码和资源,webapp为主web工程,webapp_module1为子web工程,webapp_common为基础子工程,两个we ...
- Object-oriented features
Python is an object-oriented programing language, which means that it provides features that support ...
- 'UIShell.OSGi.MvcWebExtension.BundleRuntimeControllerFactory' did not return a controller for the name 'Home'.
在使用osgi.net 框架的时候,有时会遇到这样的错误: 解决办法: 1. 检查项目文件夹下的 log 日志文件,因 osgi.net 在运行时(包括异常和操作)都会在项目的目录下生成 日志文件,并 ...
- yii中modules的命名规则
如上图,views下面的文件夹名全小写(否则会出现找不到相应视图的错误),Module文件名称第一个单词首字母大写. 总之,按照上面的格式就不会有错了~
- mysql中NULL和null的区别
接触php的web开发一段时间了,在进行数据库操作的时候经常会遇到一个问题,使得同一字段在页面显示时有3种类型NULL,null以及数字,当时的解决办法是将这一字段定义为varchar类型,在插入数据 ...
- ionic ngcordova map 地圖
幾乎每個APP都會有地圖 所以在這裏記錄一下 1.在index.html 中 <script src="https://maps.googleapis.com/maps/api/js? ...
- C# (GDI+相关) 图像处理(各种旋转、改变大小、柔化、锐化、雾化、底片、浮雕、黑白、滤镜效果) (转)
C#图像处理 (各种旋转.改变大小.柔化.锐化.雾化.底片.浮雕.黑白.滤镜效果) 一.各种旋转.改变大小 注意:先要添加画图相关的using引用. //向右旋转图像90°代码如下 ...