Android如何编程设置APP安装位置(外部存储或内部存储)?
2018-01-04 00:00
543 查看
Beginning with API Level 8, you can allow your application to be installed on the external storage (for example, the device's SD card). This is an optional feature you can declare for your application with the
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 the
If you declare "
If you declare "
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
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设置:
因此,为了能让系统把你的APP安装在外部/外置扩展存储中,你需要在manifest修改
如果你声明了"
如果你声明了 "
更多其他详细细节内容,请看原始谷歌官方文档,文档链接地址:http://developer.android.com/guide/topics/data/install-location.html#Compatiblity
android:installLocationmanifest 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 the
android:installLocationattribute 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
相关文章推荐
- (转)Android如何编程设置APP安装位置(外部存储或内部存储)?
- (转)Android如何编程设置APP安装位置(外部存储或内部存储)?
- Android如何编程设置APP安装位置(外部存储或内部存储)?
- (转)获取android手机内部存储空间和外部存储空间的参数 && 如何决定一个apk的安装位置
- android获取手机内部存储空间和外部存储空间 && 如何确定一个应用的安装位置
- 获取android手机内部存储空间和外部存储空间的参数 && 如何决定一个apk的安装位置
- 获取android手机内外部存储空间的参数 && 如何决定一个apk的安装位置 && APK安装过程及原理详解
- Android 8.0 中如何读取内部和外部存储以及外置SDcard
- Android如何将第三方预装的AP安装在data/app下面,用户可以选择卸载,但是在用户恢复出厂设置后,会再次自动安装
- Android App将数据写入内部存储和外部存储的示例
- 开发者如何控制Android App的安装位置
- 获取手机内外部存储空间的参数 && 如何决定一个apk的安装位置 && APK安装过程及原理详解
- Android App--Android apk默认安装位置设置
- Android-如何将用户设置进行保存?(内部存储、SD卡,用类作为媒介)
- Android如何将第三方预装的AP安装在data/app下面,用户可以选择卸载,但是在用户恢复出厂设置后,会再次自动安装
- Android App将数据写入内部存储和外部存储的示例
- Android&iOS:如何在外部启动app(若有安裝APP, 则自动启动app(使用 URL Schema), 若没有安装, 则询问是不是到应用市场下载)
- android 设置程序安装位置
- android 如何将一个app 设置为常住app, 不被low memory kill 关闭
- android通过manifest.xml设置程序安装的位置