The default installation location of the Android app and whether the app can be moved or not depend on the developer's androidmanifest. settings in XML: <manifestxmlns: Android = "http://schemas.android.com/apk/res/android" Android: versioncode = "1" Android: installlocation = "Auto" Android: versionname = "1.0"> Android: installlocation has three values: internalonly, auto, and preferexternal. The default value is internalonlyinternalonly, indicating that the application can only be installed in the internal storage of the mobile phone. Auto indicates that the system determines whether the application is installed in the internal storage of the mobile phone or the SD card. If there is an SD card and the application is larger than 5 MB, install it in the SD card. Otherwise, preferexternal in the internal storage of the mobile phone indicates that if there is an SD card, the application can only be installed in the SD card, otherwise, it is installed in the internal storage of the mobile phone. Android: When installlocation is internalonly, you cannot move an application to Android in the SD card and memory in "setting"-> "application"-> "manage applications: when the installlocation is auto or preferexternal, you can move the application in the SD card and memory in "setting"-> "application"-> "manage applications, in the ADB shell, you can use the PM setinstalllocation 2 command to forcibly change the installation location. 2 indicates forced installation in the SD card, 0 indicates automatic, and 1 indicates forced installation in the internal storage of the mobile phone. In the code, for mobile phones higher than Android 2.2, you can use applicationinfo. the flag_external_storage flag can determine whether the application is installed on sdcard. for mobile phones lower than Android 2.2, you can determine the APK installation location through the sourcedir attribute of applicationinfo starting with/sdcard.
Example 1Packagemanager PM = CTX. getpackagemanager (); applicationinfo appinfo = PM. getapplicationinfo (pkgname, 0); If (appinfo. Flags & applicationinfo. flag_external_storage )! = 0) {// app on sdcard system. Out. println (pkgname + "Install On sdcard ");
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