Last time I wrote a widget program, ready to add it to the mobile home page, found that the widgets I just installed the widget, the online search data only found that the system widgets can only load scan installed in memory applications, Display the widget's app to the widget list.
For developers, how can the application be automatically installed into the phone memory?
In the Android2.2 version and later, there is a property in Andoridmanifest.xml: Android:installlocation, which can be set by setting this property of three values "Auto" | "Internalonly" | "Preferexternal" to decide where to install the application.
Auto
The program may be installed on external storage media (for example, SDcard), but it will be installed to the phone memory by default, and when the phone memory is empty, the program will be installed on the external storage media. When the program is installed on the phone, users can move themselves on external storage media and phone memory.
Internalonly (default value):
When this value is set, the program can only be installed in memory, and when the phone memory is empty, the installation is unsuccessful.
Preferexternal:
The program is installed on the external storage media, but the system does not guarantee that the program will be installed on the external storage media, and when the external storage media is not available or empty, the program will be installed in memory. If the program uses the forward-locking mechanism, it will also be installed in memory because external storage does not support this mechanism. Once the program is installed, the user can also move freely between the external storage media and the memory.
When we want to know if an application is installed in SDcard, the following statements can be used to determine:
[Java]View PlainCopy
- /**
- * Determine if the application of the package name is installed on the SD card
- * @return, True if install on SD card
- */
- Public Static boolean isinstallonsdcard (String packagename) {
- Packagemanager pm = Launcherapplication.getapp (). Getpackagemanager ();
- ApplicationInfo AppInfo;
- try {
- AppInfo = Pm.getapplicationinfo (PackageName, 0);
- if ((Appinfo.flags & applicationinfo.flag_external_storage)! = 0) {
- return true;
- }
- } catch (Namenotfoundexception e) {
- E.printstacktrace ();
- }
- return false;
- }
Android lets apps automatically install to phone memory and determine if the app is installed in SDcard