"Android" Android mobile app data to SD

Source: Internet
Author: User
Tags home screen

"Android" Android mobile app data to SD

You can specify it in the application's Menifest file, include the Android:installlocation attribute in the <manifest> element, and set its value to "Internalonly", as follows:

<manifest xmlns:android= "http://schemas.android.com/apk/res/android" android:installlocation= "Internalonly" ... >

Android:installlocation also has two additional attribute values: "Preferexternal" and "Auto", which, according to the literal meaning, may also understand what it means, or the following:

If you define "preferexternal", it means that you require your app to be installed in the extended storage, but the system does not guarantee that the app will be installed to the extended storage. If there is no space for the extended storage, the system installs the app to the built-in storage. Users can move your app between two locations.
If you define "Auto", your app may be installed in extended storage, but there is no particular preference for the installation location. The system will determine where your app is installed based on a number of factors. Users can also move an app between two locations

When we used the Android phone, we found that some programs allowed to be moved to the SD card, and some not? What is this for?

Android apps are allowed to move to the SD card after Android version 2.2. None of the applications developed before has this feature.

So how exactly does it allow your app to move to the SD card? The answer is simple, just set a InstallLocation property for manifest.

This property sets the default installation location, with a total of three valid values,auto, internalonly, preferexternal.

Auto means automatic, the system determines the installation location

Internalonly installed in Phone memory

Preferexternal installed in external storage


Take a look at the modified androidmanifest.xml.

  

<xmlns:android= "http://schemas.android.com/apk/res/android"package         = "COM.YFZ"        android:installlocation= "Auto"        Android:versioncode  = "1"        android:versionname= "1.0">


Isn't it simple?

Someone might ask, what if my support is 2.1? In fact, you just set the <USES-SDK android:minsdkversion= "7"/> and then install to the 2.1 device, Android will ignore this property, directly to you to install to the phone memory.

It is important to note that not all programs are suitable for moving to an SD card. The following is a look at, under what conditions, it is not recommended to allow the program to move to the SD card.

 

Applications that should not Install on External Storage

When the user enables USB mass storage to share files with their computer (or otherwise unmounts or removes the external s Torage), any application installed on the external storage and currently running are killed. The system effectively becomes unaware of the application until mass storage are disabled and the external storage is Remou Nted on the device. Besides killing the application and making it unavailable to the user, this can break some types of applications in a more Serious. In order for your application to consistently behave as expected, you should not allow your application to be installed on The external storage if it uses any of the following features, due to the cited consequences when the external storage is Unmounted:

Services
Your running Service would be killed and would not being restarted when external storage was remounted. Can, however, register for the action_external_applications_available broadcast Intent, which would notify your Applica tion when applications installed on external storage has become available to the system again. At which time, you can restart your Service.
Alarm Services
Your alarms registered with Alarmmanager would be cancelled. You must manually re-register any alarms then external storage is remounted.
Input Method Engines
Your IME is replaced by the default IME. When external storage was remounted, the user can open system settings to enable your IME again.
Live Wallpapers
Your running live wallpaper would be replaced by the default live wallpaper. When external storage is remounted, the user can select your Live wallpaper again.
Live Folders
Your Live Folder is removed from the home screen. When external storage was remounted, the user can add your Live Folder to the home screen again.
APP Widgets
Your App Widget is removed from the home screen. When external storage is remounted, your App Widget won't be available for the user to select until the system resets T He home application (usually not until a system reboot).
Account Managers
Your accounts created with Accountmanager would disappear until external storage is remounted.
Sync Adapters
Your Abstractthreadedsyncadapter and all it sync functionality won't work until external storage is remounted.
Device Administrators
Your Deviceadminreceiver and all its admin capabilities'll be disabled, which can has unforeseeable consequences for th E device functionality, which may persist after external storage is remounted.
Broadcast receivers listening for "boot completed"
The system delivers the action_boot_completed broadcast before the external storage is mounted to the device. If your application is installed on the external storage, it can never receive this broadcast.
Copy Protection
Your application cannot is installed to a device's SD card if it uses Android market ' s Copy Protection feature. However, if you use Android market ' s application Licensing instead, your application can is installed to internal or exter NAL storage, including SD cards.
If your application uses any of the features listed above, you should not allow your application to install on external St Orage. By default, the system won't allow your application to install on the external storage, so you don ' t need to worry Abou T your existing applications. However, if you ' re certain that your application should never is installed on the external storage and then your should make T His clear by declaring android:installlocation with a value of "internalonly". Though This does no change the default behavior, it explicitly states that your application should only being installed on T He internal storage and serves as a reminder to you and the other developers so this decision have been made

The above paragraph must be seen, it is very important. For example your program if you want to boot from the boot, it must not be allowed to move to the SD card. Because the broadcast message boot_complete the boot is sent before the SD card is loaded, the program cannot receive it at all.

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.