Difference between auto and preferExternal instal location Android manifest - android

What is the difference between auto and preferExternal instal locations in android manifest? Both options can instal application on External memory. Is it something big and important? Which is better to set?

If you declare preferExternal, you request that your application be installed on the external storage, but the system does not guarantee that your application will be installed on the external storage. If the external storage is full, the system will install it on the internal storage.
If you declare auto, you indicate that your application may be installed on the external storage, but you don't have a preference of install location. The system will decide where to install your application based on several factors. The user can also move your application between the two locations.
reference
http://developer.android.com/guide/topics/data/install-location.html

Related

Confusion in External Storage in android

1)Question
I have used installLocation in manifest
android:installLocation="preferExternal"
Correct me if i am wrong. android:installLocation="preferExternal" make your app install on external sdcard . If this is true then i should not be able to use myapplication when sdcard is removed . But however i can use myapplication even when i removed sdcard from my device
2)Question
what is the difference between sdcard0 and extsdcard on my device ?
even when i use in my manifest
android:installLocation="preferExternal"
all app files are stored on sdcard0 and it is accessible even when i have sdcard in my device . i have used below method to store files on sdcard
Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS);
So in which condition my files will be stored on my sdcard ?
and how can i store files on extsdcard?
1) As stated in the docs:
If you declare "preferExternal", you request that your application be
installed on the external storage, but the system does not guarantee
that your application will be installed on the external storage.
Unmounting the external storage means that all running apps that were installed there will be immediately killed. If you are still able to use your app, I see 2 possible reasons: the system decided to install your app on the internal storage OR your device also features an emulated "external" storage and your app was installed there.
2)
what is the difference between sdcard0 and extsdcard on my device
It's common that sdcard0 refers to the device internal storage while extsdcard refers to the external storage that might be physical or emulated. However there's no reliable naming convention, it's up to the vendor.
Also note that "external" an Android basically means "a storage that the user can access".
A few further steps that might help:
use ADB Shell to examine your device's storage structure, with SD card attached and detached
verify your app's install location from the "Apps" settings menu
Log absolute paths of directories provided by different methods of the Environment class
Note: generally, you should never rely on assumptions of your app's install location since that might get you in trouble on some devices

Force app to install on internal storage

I want my app to be installable only on internal storage.
I have tried two options:
Not specifying any storage preference in the manifest (the Docs say that this forces the app to install only to internal storage)
Explicitly specifying android:installLocation="internalOnly" in the manifest
In both cases, when I try to install it on a tablet that's running Android 4.4.2, Kernel 3.4.67, and having an SD card, it prompts me to select whether the app should be installed on Tablet Storage or the SD card.
The tablet has ample free internal storage (9 GB). The default write disk is also set to Internal Storage.
Is there any way to bypass this prompt and install to internal storage after the user approves the permissions needed by the app?
According to the docs, the flag you are using should not allow install on the SDCARD or any external storage. This appears to be a bug.
Post at the bug location to help give it attention.

how to use manifest tags

i set in my AndroidManiifest.xml
android:installLocation="internalOnly"
my question is if the internal memory is full and when we want to install the app to device can be installed on external memory?
The documentation is rather clear on that:
The application must be installed on the internal device storage only. If this is set, the application will never be installed on the external storage. If the internal storage is full, then the system will not install the application. This is also the default behavior if you do not define android:installLocation.
Using android:installLocation="auto" if the internal memory is full the system will install the app on the external memory.

How to force android to install app on internal memory

I've an app that i download from private server, it installs ok on most phones but i'm having problems installing it on a HTC Desire C. The phone has no sdcard present. I've searched around and found a manifest setting that should hint at internal storage or say that there is at least no preference to where the app is installed.
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.carefreegroup"
android:versionCode="1"
android:versionName="1.0"
android:installLocation="auto" >
This does not work however.
How can i tell android that the app MUST be installed on the internal memory
Thanks Matt
set in Manifest
android:installLocation="internalOnly"
this will install app in internal storage and will not install it at all if there is no space in internal memory
http://developer.android.com/guide/topics/manifest/manifest-element.html
The attribute android:installLocation can have following possible values.
internalOnly: The application must be installed on the internal device storage only. If this is set, the application will never be installed on the external storage. If the internal storage is full, then the system will not install the application. This is also the default behavior if you do not define android:installLocation.
auto: The application may be installed on the external storage, but the system will install the application on the internal storage by default. If the internal storage is full, then the system will install it on the external storage. Once installed, the user can move the application to either internal or external storage through the system settings.
preferExternal: The application prefers to be installed on the external storage (SD card). There is no guarantee that the system will honor this request. The application might be installed on internal storage if the external media is unavailable or full, or if the application uses the forward-locking mechanism (not supported on external storage). Once installed, the user can move the application to either internal or external storage through the system settings.
According to the docs if you do not set that preference, the app will be installed on internal storage and it won't be movable.

How to prevent Android app installation if SDCard absent?

My code logic needs an SD card installed in the device. I have added a check for this case in the application's splash screen, but would like to inform users before they download/install this app. Is there a way to achieve this ?
Thanks !
There is no way to do this before the app installs, as the only way to limit such things is by using the <uses-feature> tag. However, that tag has no options for storage requirements. The best warning you can give is to prominently include it in your app description.
On the other hand, every device I've ever heard of an encountered has some form of external storage, be it a SD Card or inbuilt memory mounted as external storage. What you're doing by using the Splash Screen to check for the external storage is the best way to do this, as there is no other option.
There's no way to do that. Your app have to be installed to be able to check user's environment. You could try to to enforce SD card installation of your app, so if there's none Google Play might (not tested) simply not allow app installation at all, but it will not solve your problem as user will still do not know why. Solution is to clearly state in product description that SD card is mandatory. But note, that requiring SD card is risky as many devices does not have any while still offer external storage. My suggestion - just add note about storage requirements and let system deal with it.
I think it is NOT POSSIBLE . You are checking the sdcard on splash screen and prevent user for next process is the right solution or Use android:installLocation for install android application on sdcard.
Beginning with API Level 8, you can allow your application to be
installed on the external storage (for example, the device's SD card).
This is an optional feature you can declare for your application with
the android:installLocation manifest attribute.
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
android:installLocation="preferExternal"
... >
If you declare "preferExternal", you request that your application be
installed on the external storage, but the system does not guarantee
that your application will be installed on the external storage. If
the external storage is full, the system will install it on the
internal storage. The user can also move your application between the
two locations.
When your application is installed on the external storage:
There is no effect on the application performance so long as the
external storage is mounted on the device.
The .apk file is saved on the external storage, but all private user
data, databases, optimized .dex files, and extracted native code are
saved on the internal device memory.
The unique container in which your application is stored is encrypted
with a randomly generated key that can be decrypted only by the
device that originally installed it. Thus, an application installed
on an SD card works for only one device.
The user can move your application to the internal storage through
the system settings.
Look Here for more details .

Categories

Resources