I want to know,
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.
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?
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
Related
I have an android app running on Chromebooks. I'm using FileObserver to watch a few common directories and notify changes. This is successful in all locations except the downloads directory on my chromebook.
Downloads directory on this specific chromebook is /storage/MyFiles/Downloads. Do chrombook downloads directories have special protections? (are we not allowed to monitor there?)
If this is a security issue or otherwise intentional and you have a source, please share it
This is how the device filesystem looks in AS:
I am taking an Android app and making it run on Chrome using the ARC Welder. For best results we're only targeting the Chromebook / Chrome OS, not Windows or OSX.
The app is running with some minor glitches, but I need to enumerate photos on an inserted SD card.
The problem is that the /mnt folder accessible within Android Runtime only contains the virual sdcard folder, and does not reflect the real SD Card or USB Flash Drives attached to the Chromebook.
How can these photos be automatically loaded from the SD Card into the Android App in the Android Runtime.
I know that I could use a CRX (Chrome Extension) to read the SD Card photos, but how could they be passed to the Android app? And can this be in the same CRX as the ARC Welder creates or must it be a separate CRX?
I found a workaround which is to use the Additional Metadata section and add
{ "enableExternalDirectory": true }.
When the app first launches, it prompts the user for the folder. One must select the SD card.
Then my app works as expected, as the 'emulated sd card' becomes the 'real sd card'. This is not the most user-friendly approach, but it works.
I'd still prefer if we could load the files from a CRX into the Android Runtime...
I'm confused with Android emulators. Either emulator for Android KitKat or Lollipop doesn't emulate external disk writing properly.
Both of the Android versions are supposed to prevent applications to make modification on external disk (writing or modifying), even though the app has defined
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
I tried in Android official emulator and also in Genymotion.
When you create a new AVD and set up an SD Card, you add a primary external storage to the emulator. Android from version 4.4 prevents the modification of secondary external storage as you can see here:
The WRITE_EXTERNAL_STORAGE permission must only grant write access to
the primary external storage on a device. Apps must not be allowed to
write to secondary external storage devices, except in their
package-specific directories as allowed by synthesized permissions.
Restricting writes in this way ensures the system can clean up files
when applications are uninstalled.
For this reason your app can write to the external storage in the emulator.
Unfortunately the default emulator cannot emulate secondary external storage.
I am developing an application that has the following requirement:
When the device is connected to a computer via USB, the user should be
able to use Windows Explorer to drag files into and out of the
application directory.
The application will consume some of these files and produces others
which should be able to be copied back to the computer.
The target device does not have an external storage device (for
example an SD Card).
The directories that the files will be stored in should be accessible
whilst the application is running.
I've looked into the data storage page in the android documentation, but none of the methods stated there seem to do what I require.
Alternatively, is there a way to select the computer when the application is running and 'send' files via USB to the computer? How about for 'receiving' files?
What is the best way to fulfill this requirement?
When the device is connected to a computer via USB, the user should be able to use Windows Explorer to drag files into and out of the application directory.
If "the application directory" refers to a spot on external storage, this is possible.
The application will consume some of these files and produces others which should be able to be copied back to the computer.
If this is supposed to happen simultaneously, the device must be running Android 3.x or higher. Android 1.x and 2.x did not support simultaneous access to external storage.
The target device does not have an external storage device (for example an SD Card).
It needs to have something designated as "external storage". That does not have to be removable storage. On Android 3.x and 4.x, it is usually just a part of on-board flash that was designated to be accessible as external storage. In Android terms, "external storage" means "can be accessed by a host computer using USB and by all applications on the device as well".
The directories that the files will be stored in should be accessible whilst the application is running.
Again, this requires Android 3.x or higher. If this is a custom device, that most likely means you are going to need to use the recently-released Android 4.0 source code.
Alternatively, is there a way to select the computer when the application is running and 'send' files via USB to the computer? How about for 'receiving' files?
No and no, respectively.
What your going to want to do is use Environment.getExternalStorageDirectory. Even if there is no sd card, most android devices partition a part of the on board memory to be used as external storage.
Is that possible for android to install all the apps on SD card once the SD card insert in the phone.
Is that possible to build something like the auto run application in flash disk on windows,
here in android the apps are all stored in sd card , i am finding a way to install them once the card insert into phone.
No. Android wisely won't do that.
If you want you can write an application which will scan the sdcard (perhaps even automatically on insertion) for apks and use an intent to bring up the install dialog. But the user will first have to install your application, and confirm the installation of each new app from the sdcard. Also the device will have to be set to allow non-market sources.