Changing android:installLocation from preferExternal to internalOnly - android

I have an app on Google Play market and I added android:installLocation="preferExternal" to manifest.xml file and released long time ago. Now I would like to add Android home screen widget, so I need to change it to android:installLocation="internalOnly". If I do that, what happens when a user upgrades? because a user already installed the old app on SD card. What is the best solution for this situation??
If someone has this kind of experience, please advise me.
Thanks in advance :)

When you set install location to preferExternal the application specific files are stored in .android_secure directory in external sdcard.
These type of application are not available when user mounts the SD Card as USB Mass Storage (feature removed from Android Jelly Bean).
Coming to the question, I believe in your case the application would be installed onto internal memory with the files from .android_secure moved to internal location.
You can confirm this by the following:
Install the application from play store having install Location as preferExternal.
Confirm that your application is installed in external SD card, you can use Settings->App to check that.
Now create your new signed application package.
Install using adb install -r myapp.apk
Again goto Settings->App and confirm the location.
Run functional test to see if nothing is broken.

Old question, but according to my test, if an app is installed on SD card and you change afterwards the Manifest to android:installLocation="internalOnly" (or omit the android:installLocation attribute, which is the same), when the app is upgraded the package manager will automatically move the app from SD Card to internal storage.
No idea what happens if this is not possible (not enough root on internal storage for example).

Related

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.

Get application install location (system or sdcard)

Is it possible to check info about the android:installLocation of my app, if it is installed on /data/app or on SD card?
I need to check if my app moved to SD card then need notify user that the autostart doesn't work.
I used this answer to get application install directory How to get app install directory
Hope it helps

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 .

Moving installed apps on Android to external storage

My requirement is to be able to move all apps installed on the device(tablet) to an external SD card with the click of a button.
My research says, unless a .apk file have a manifest attribute installLocation specified as auto or preferExternal, the app cannot be moved.
Using PackageManager class allows me to get a list of all files installed on the device.
But I cannot find how to move an app, is it possible?
It is not possible to move apps to external storage if they are not specified as being allowed to, unless your device is rooted.

How to install an apk stored in private storage of android application?

From my android app, I'm downloading an apk from the web, storing it in application's private storage (openFileOutput(FILENAME, Context.MODE_PRIVATE))
and trying to call the android package installer for this downloaded apk by,
intent.setDataAndType(Uri.fromFile(f), "application/vnd.android.package-archive");
startActivity(intent);
but I'm getting an error which says
Unable to open zip: /data/data/com.test/files/abc.apk : Permission denied
in the LogCat
and,
Parse Error: There is a problem parsing the package
on the phone screen.
Is it happening because the apk file is in application's private storage so the Android package installer can't access it? If yes, is it somehow possible to still get the apk installed (with user's permission of course.) or Am I doing something wrong?
PS: Please don't assume the phone to be rooted.
In addition to Mark Allisons comment, my GUESS is that since you have the file saved to private storage with mode_private, only your application has read/write permission. But you are trying to have the package installer read it which means that the file must be accessed by an External application and therefore should either be MODE_WORLD_READABLE or MODE_WORLD_WRITEABLE.
Or you could save it to external storage where it is world readable by default.
Ok, for now I've figured out a workaround (and which helped me confirming the exact problem also- the problem was that installer couldn't access the apk file). Now, I'm using MODE_WORLD_READABLE instead of MODE_PRIVATE while saving the file in internal storage, and the android installer is able to access the apk and can install it without any error.
Actually, for me the main purpose of using internal storage was that users shouldn't be able to copy the apk file directly (assuming a simple threat model in which a user doesn't have rooted phone, but can browse through the SD card to find the apk and copy it). Though I'm still not sure whether the file is visible to a user now or not? I mean I'm (almost) fine if the downloaded apk can be accessed from an app in the phone, but can't be copied directly by the user.
Would be helpful if someone knowing the exact scope of MODE_WORLD_READABLE could elaborate on the same, specifically whether a file saved in this mode can be browsed in the (unrooted) phone. Also, is it possible to have a better strategy to safeguard the apk while still allowing the installer to access it?
MODE_WORLD_READABLE does say that it can be accessed by whole "world on the phone" so other apps can get it including file explorers. Some programs like es-file manager let you see contents on device private storage even if you are not rooted but don't let you change those files. Why don't you just delete apk file immediately after installation ? Also since you are downloading apk file in your application I am guessing you don't want to use play store but if that is not an issue see Licensing options for your app on: http://developer.android.com/google/play/licensing/overview.html since there is probably use case that covers your requirements.

Categories

Resources