Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What happens while moving app to SD Card in Android

I want to know,

  1. What happens to app data/database files/ etc while moving app from internal storage to SD card and vice versa?

Also I have an app which is installed in external storage. Im upgrading the app. The latest version of the app has flag to restrict install only in internal storage.

  1. Will this latest app get installed in internal storage? Will the system automatically move the app data from external to internal or the data from previous installation is lost?
like image 398
Karthik Avatar asked Jul 17 '15 07:07

Karthik


People also ask

What happens when apps are moved to SD card?

If your Android phone has an SD card slot, you can move apps out of internal storage. Storing apps on an SD card can free up space on your phone for other apps and data.

Is it OK to move app data to SD card?

The good news is that if your device comes with expandable storage, you'll be able to move apps to an SD card. Additionally, you can turn your microSD card into internal storage. This will effectively make it possible to move apps to your SD card and all other data you may have on your phone.

Can you move apps to SD card and still use them?

Note: Only some apps can be moved to a memory card. Tap Storage. If the app supports changing where it's stored, a CHANGE button appears → tap CHANGE. Tap SD Card → MOVE.

What happens when you move files to SD card?

The benefit of saving your files to your SD card or other external storage for that matter, is that you can swap them to a different device. This is particularly helpful when you want to share data with another device, upgrade your own device efficiently, or move files to long-term backup or storage.


1 Answers

Actually this does not seem a programatic question is more an Android OS question.

First. As developer you don't choose HOW your app is installed, but since Android 2.2 you can choose WHERE:

Existing applications that were built prior to API Level 8 will always install on the internal storage and cannot be moved to the external storage

Since android API 8:

android:installLocation
internalOnly: Install the application on internal storage only. This will result in storage errors if the device runs low on internal storage.

preferExternal: The android system tries to install the application on external storage. If that is full, the application is installed on internal storage.

auto: Let the Android system decide the best install location for the application. The default system policy is to install the application on internal storage first. If the system is running low on storage, the application is then installed on external storage.

As long as you programatically don't define the installation / moving process, Android operating system will take care of moving (if possible) from internal to external and viceversa. But as programmer you must be carefull with the type of app you are developing to know if you should or not allow this option

Warning: When the user enables USB mass storage to share files with a computer or unmounts the SD card via the system settings, the external storage is unmounted from the device and all applications running on the external storage are immediately killed.

What happens: As long as you don't decide, let's explain in a simple way. All files of the app are moved to sd card except one little pointer in the internal storage that tells the system where the app is located. (imagine if you format your SD card manually, then your phone won't know app has dissapeared) but if you unmount it phone won allow you to access.

Second Application updates will by default try to retain their install location, but application developers may change the installLocation field in an update. Installing an application with this new attribute on older devices will not break compatibility and these applications will be installed on internal storage only. That means, older data will be moved as long as the app remains with same identifier (and signature if market app).

Source / Source

ADVANTAGES / DISAVANTAGES

To keep / update your database files / configuration when upgrading your app check here and here

like image 50
Jordi Castilla Avatar answered Oct 29 '22 07:10

Jordi Castilla