App installation location for Android data storage

Source: Internet
Author: User

Original address: Http://developer.android.com/guide/topics/data/install-location.html#Compatiblity

From API8, you can install your app on an external storage. This is an optional feature that you can declare in your app's manifest: Android:installlocation property. Assuming that you do not declare this attribute, your application will be stored internally and cannot be moved to an external storage.

<manifest   xmlns:android  =   "/http" Schemas.android.com/apk/res/android "      android:installlocation  =   "preferexternal"      ...  >  
When you declare the preferexternal, you ask your application to install the external storage, but the system is not sure that your program must be installed in the external storage. If the external storage is full, it will be stored in the built-in storage. Users can also move your app between two stores. If you declare auto, you indicate that your application can install external storage, but you do not have an installation location preference. The system depends on a number of factors to determine where your application is installed. Users can also move your program between two stores.

When your app is installed in the external storage:

1. When your external storage is mounted on your device, it has no effect on your app's operation.

2..apk files will be stored in external storage, but all private user data, databases, optimized. dex files, and extracted local code will be saved in the built-in storage.

3. Your app's installed container uses a randomly generated key encryption and can only be decrypted by the device that installs the app, ensuring that only one application is in the same sdcard.

4. The user is able to move your app to the built-in storage via system settings.

Note: Applications executed in the external storage will be killed immediately when the user uses USB storage and computer to share files or to uninstall SD Card via system settings.


Forward compatible

Applications installed before API8 will be installed in the built-in storage and will not be moved to external storage.

But your app can be set up to support less than API8:,

1. Set Android:instailllocation to Auto or perferexternal in <manifest>.

2. Do not change the minsdkversion, and ensure that your application code is compatible

3. In order to compile your application, change your build target to API8, because the low Android library does not recognize the Instailllocation property and does not compile your application.


Applications that do not install external storage

Users use USB storage and computer sharing files or the system settings to uninstall SD Card, the application executed in the external storage will be killed immediately.

To make your app work as expected, assume you're using a feature you can't install your app in external storage.

1. Service: The service you perform will be killed and will not be restarted when the external storage is mounted. But you can register a ACTION_EXTERNAL_APPLICATIONS_AVAILABLE的广播intent,这样当你外置应用变得可用的时候会被提醒。

2. Alert Service: Your service with Alarmmanager will be canceled and you must register again when the external storage is being mounted again.

3. Enter the method engine: Your IME will be replaced by the default IME.

4. Live Wallpaper: The wallpaper You are performing will be replaced by the default live wallpaper.

5.APP Widget: Your appwidget will be removed from the desktop.

6. Account management: Accounts created with Accountmanager will disappear.

7. Sync Adapter: Your abstractthreadedsyncadapter and all of its syncing methods will not work.

8. The receiver of the"Boot completed" broadcast: The system will emit a action_boot_completed broadcast between the external storage device, and you will not receive this broadcast if you install an external storage application.

Applications that require the installation of external storage

Out of the list above, other applications can be installed in the external storage, the big game is usually installed in the external storage, because the game does not need to provide additional services when it is inactive, when the external storage is not available, the game will be killed, when the external storage becomes available and the user restarts the game, There should be no visible effect (if the game is properly saved in its normal activity life cycle)

When your app needs megabytes of apk files, you should carefully consider when the app should be installed in the external storage, so that the user saves the built-in storage space.

App installation location for Android data storage

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.