Android 安装位置 - installLocation简析

在Froyo(android 2.2,API Level:8)中引入了android:installLocation.通过设置该属性可以使得开发者以及用户决定程序的安装位置. android:installLocation隶属于AndroidManifest.XML中的manifest节点.如下所示:

<manifest xmlns:android=“http://schemas.android.com/apk/res/android”  
    package=“org.teacup.testbannerimg”  
    android:installLocation=["auto"|"preferExternal"|"internalOnly"]   
    android:versionCode=“1″  
    android:versionName=“1.0″ >  
… other code…    
</manifest>
android:installLocation可以设置为"auto"、"internalOnly"、"preferExternal"三个值中的任何一个.

  • auto:程序可能被安装在外部存储介质上(例如:SD Card),但是默认会被安装到手机内存中.当手机内存为空时,程序将被安装到外部存储介质上.当程序安装到手机上后,用户可以决定把程序放在外部储介质还是内存中.
  • internalOnly:.当设置为该值时,程序只能被安装在内存中,如果内存为空,则程序将不能成功安装.
  • preferExternal:将程序安装在外部存储介质上,但是系统不保证程序一定会被安装到外部存储介质上.当外部存储介质不可以或空时,程序将被安装到内存中.程序使用了forward-locking机制时也将被安装到内存中,因为外部存储不支持此机制.程序安装后,用户可以自由切换程序应该在外部还是内部存储介质上.
 

你可能感兴趣的:(Android 安装位置 - installLocation简析)