Android:installlocation = usage of "Auto"

Source: Internet
Author: User
Tags stmt

Android:installlocation was introduced in Froyo (Android 2.2,api level:8). Setting this property allows developers and users to determine where the program will be installed.

The android:installlocation belongs to the manifest node in the Androidmanifest.xml. As shown below:

<Manifestxmlns:android= "Http://schemas.android.com/apk/res/android" Package= "string"Android:shareduserid= "string"Android:shareduserlabel= "string resource"Android:versioncode= "integer"Android:versionname= "string"android:installlocation=["Auto"| "Internalonly" | "Preferexternal"]>    . . .</Manifest>
Android:installlocation can be set to any of the three values of "auto", "internalonly", "preferexternal".

    • Auto: The program may be installed on external storage media (e.g. SD Card), but it will be installed to the phone memory by default. When the phone memory is empty, the program will be installed on the external storage media. When the program is installed on the phone, the user can decide whether to place the program in an external storage medium or in memory.

    • Internalonly: Default value. When set to this value, the program can only be installed in memory, and if the memory is empty, the program will not install successfully.

    • Preferexternal: The program is installed on an external storage medium, but the system does not guarantee that the program will be installed on the external storage media. When external storage media is not available or empty, the program is installed in memory.

Programs that use the forward-locking mechanism will also be installed in memory because external storage does not support this mechanism. After the program is installed, the user is free to switch whether the program should be on the external or internal storage media.

Note: When the program uses the Copy protection feature of Google Play, it can only be installed in memory.
When the program is installed on an external storage medium,
The ①.apk file will be moved to the external storage media, but the program's data will still be in memory
② the container where the. apk file is saved will be encrypted with a randomly generated key, so that only the settings for that program can use the data that exists on the external storage media.
Warning: When external storage media is uninstalled, programs installed on that external storage media will be terminated immediately!

Backward compatibility:
Android:installlocation is declared, but Android:minsdkversion is less than 8 o'clock, we compile with an AVD of no less than Froyo, so android in a system below Froyo: InstallLocation will be ignored, and no less than fro Yo's system would use our designated android:installlocation.

We should not install the program on external storage media when our program has the following behavior
①service
The running service will be terminated and the service will not be restarted when the external storage media is reloaded.
②alarm Service
The alarm service will be canceled and the developer must re-register the alarm service after the external storage media is reloaded.
③input Method Engines
Input method will be replaced by the system input method, when the external storage media is reloaded, the user can use the system settings to start our input method
④live Wallpapers
Our live wallpaper will be replaced with the default live wallpaper. After the external storage media is overloaded, the user can change back.
⑤live Folders
Our dynamic folder will be moved out.
⑥app Widgets
Our widgets will be moved out, and our widgets are usually available only after the system restarts.
⑦account Managers
Accounts created with Accountmanager will disappear until the storage media is reloaded.
⑧sync Adapters
Our sync feature is only available when external storage media is reloaded
⑨device Administrators
Our deviceadminreceiver will be void.
⑩ Monitoring Boot End Event
Action_boot_completed broadcasts are sent before the external storage media is loaded. Therefore, programs installed on external storage media will not be able to accept power-on broadcasts.
In general, we can install our programs on external storage media as long as we do not use the above features. For example, a large game program. When our APK file is a few m large we should seriously consider whether to move the program to external storage media to help users save memory.

Google's default packagemanager will read the corresponding definition of the app Androidmanifest.xml InstallLocation:

The rules are as follows:

1. If the installation location is not defined, it is installed on the phone memory;

2. android:installlocation = "Auto", first check the phone memory is sufficient, if enough is installed in the phone memory, not enough to install on the T card;

3. android:installlocation = "internalonly", which means the device is installed on the phone memory;

4. android:installlocation = "preferexternal", means installed on the T card;

How do I add the "Choose App Install Location" feature in the settings to let the user choose the default installation location?

Modify the following file:
Frameworks/base/packages/settingsprovider/src/com/android/providers/settings/databasehelper.java

Make the following changes:
Loadsetting (stmt, global.set_install_location, 0);

Switch
Loadsetting (stmt, secure.set_install_location, 1);

Loadsetting (stmt, Settings.Secure.SET_INSTALL_LOCATION, 0);

Switch
Loadsetting (stmt, Settings.Secure.SET_INSTALL_LOCATION, 1);

After this modification, the "Choose App Install Location" feature appears in Settings > apps, but no matter what you choose here, the Androidmanifest.xml file in the app is declared
Android:installlocation = "Internalonly"

, the APK will be installed on the phone, the benefit is to avoid the program run error, because the definition of android:installlocation = "Internalonly" APK is generally installed to the phone memory to function properly.



REF:

Android modifies the app's default installation location
Http://www.th7.cn/Program/Android/201411/321349.shtml

A brief analysis of Android:installlocation-lefter-Blog Park
Http://www.cnblogs.com/Lefter/archive/2012/03/07/2383962.html

Android:installlocation = usage of "Auto"

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.