Android: Force Moving Apps to an SD Card | Comments (94)
Posted in Linux/Unix, Mobile on 2nd February 2011, 7:19 pm by Stuart

This isn’t anything new but I thought I would share my experiences of trying to free space on my HTC desire by forcing apps to be movable to the sd card using the android SDK on linux.
WARNING: Ensure you have a backup of any important data before you start in case something goes wrong. Carrying out these instructions is at your own risk.
Running out of space is really the only annoyance I have come across since owning an android phone. Every now and again the low space icon comes up and you have to try and free up some space.
Since Froyo you’ve been able to move certain apps to SD card, but it’s only if the developer allows it. If you’re an android developer and you want to know how to do it, see this post: Enabling the Android Move To SD Card Feature
So if you’re stuck with a bunch of apps you can’t move by default because “Move to SD Card” is greyed out in “Settings -> Applications -> Manage Applications -> Appname” then you might be thinking it’s not possible. However, it is possible to change the default install location to SD card via adb.
Introducing the Android Debug Bridge
Adb is the Android Debug Bridge which comes as part of the SDK. If you don’t have the SDK the first thing you will need to do is install it (get it fromdeveloper.android.com). Once you have the SDK you can find the adb tool in <sdk>/platform-tools/, though in my case I have it at <sdk>/tools/.
Update 2012-01-26: You may find when you unpack the SDK adb isn’t there. If that’s the case you may need to run the “android” program (./android under linux) to be shown a window which provides a way to download platform-tools. once you have installed that you should find adb there.
After you’ve installed the SDK you’ll need to connect your phone to your computer using the USB data cable. You’ll also need to make sure that debugging is possible by visiting “Settings -> Applications -> Development” and checking “USB Debugging”.
Enabling moving of apps to SD card
To change the the install location we are going to run the pm command via the adb shell. Here’s the details of the pm command:
The setInstallLocation command changes the default install location
0 [auto]: Let system decide the best location
1 [internal]: Install on internal device storage
2 [external]: Install on external media
To change the default install location to the SD card (which also enables moving most apps to the SD card.) run the following from the dir containing the adb command:
./adb shell pm setInstallLocation 2
If you at any point hit the following:
error: insufficient permissions for device
Try doing this:
./adb kill-server
sudo ./adb start-server
You should now find you can run the above commands without error.
Insufficient Storage Available
The other error I had was that when I was trying to move any app after changing the default install location to the SD card was something along the lines of “Unable to move application. Insufficient Storage”.
The way I got around this was to uninstall twitter which was using about 17mb (it was the largest app). After that I re-installed it and it used far less space (naturally as the data would have been removed by the re-install process). After that I was able to successfully move most of my remaining apps (twitter included) to my SD card.
Re-setting the installation location back to auto
I’d strongly recommend re-setting the default installation location when you are done moving apps. The reason for this is that apps will fail to be installed directly to the external location, at least this is what I experienced when trying to re-install the twitter app.
To reset the install location to automatic (let the system decide) use the following:
./adb shell pm setInstallLocation 0
Should you forget where it was left at you can always run:
./adb shell pm getInstallLocation
e.g:
$ ./adb shell pm getInstallLocation
0[auto]

Just YMMV: This totally corrupted my SD card – lots of photos lost.
@Chris I’m very sorry to hear that.
It’s hard to say with absolute certainty if changing this setting could contribute indirectly or directly to an SD card failing in such a way.
However, in any case I’ve added a warning to the top of the post that anyone trying these instructions should ensure they have a backup just in case.
Works like a charm!
This is why I love Linux. I have been fooling around with this for two days already on Windows with no success and solved it in minutes under Linux (thanks to you that is).
The only thing I have to suggest for you is to better explain how to install the sdk but considering the topic here this isn’t what a newcomer to android would look for in any case, ah the power of search
btw I don’t know if it has to do something with Chris above but…have you turned off the debugging on your phone?
It won’t read from the sd if it’s checked, I think so.
Rooting is a pain for me.
Thanks again!
Great post, thank you.
Can you clarify- will this move already installed apps to the SD card, or only apps which are installed after running the above commands?
Thank you,
Neil
@Neil: this just changes the default location that apps are installed to and also makes it possible to move apps that weren’t previously able to be moved to the SD card.
I’d personally recommend making the setting change, then move the apps you want to move and then set it back to the default.
Hi Stuart,
Thanks for the quick reply. I have installed the necessary SDK and accosiated files. I have found adb in the platform-tools folder.
WHen i click on adb, I get a command window open breifly, then it vanishes. How do I enter the neseccary script ./adb shell pm setInstallLocation 2 ??
Thanks again,
Neil
sorry, meant to add that in the command prompt window I keep getting the response “adb is not recognised….”
@Neil: on linux you’ll need to open the folder that contains the adb executable in the terminal and from there you should be able to run the commands as listed.
OK it’s getting late and I think i’ve had enough for one night!
Rather than post question after questions here, perhaps I can email you for further help Stuart?
I’ve made some progress and hit another stumbling-block, i’ll take a screen shot and send on.
Kind Regards,
Neil
All I’m getting whenever I try any of the commands is:
-bash: adb: command not found
What am I doing wrong?
Here is a copy of what I tried:
@ben: First ensure the android sdk is installed.
Then, if you’re not in the directory that adb lives in then adb will need to be on your path.
e.g (in your ~/.bashrc or ~/.profile)
export PATH=/path/to/adb/dir:$PATHTo get that to work immediately you’ll need to subsequently run:
source ~/.bashrcIf you are in the directory that adb is in then you need to use
./adbinstead ofadbat the prompt.Hope that helps.
Stuart
I bought the Cruz Reader R101, totally unaware of what I was getting into. I have a HTC T-Mobile G2 with Android OS 2.2. I am in love with this phone, so I was expecting a very similar experience from the reader. I knew it had Android OS 2.0 on it but did not read the manufacturer’s website saying that there will be no upgrade for this device above 2.0.
No I can’t install more than 4-5 five apps without the little out of space notice coming up.
Can I try this method for the Cruz Reader, if anyone knows?
I’ll have done everything correctly without any error messages. Rebooted the phone. But my “Move to SD Card” button is still grey. My phone is rooted and using android 2.2.
Excellent hack! Works perfectly on Gingerbread.
The tip about how already installed apps which cannot be shifted can be shifted after this modification is especially useful
Thanks worked like a charm on a stock HTC Wildfire S running Gingerbread 2.3.3. Limited internal memory no longer such a big issue. Still a minority of apps refuse to be moved (looking at you Cozi) but just freed up 20 Mb of internal storage and phone now seems faster. Cheers
Got my HTC EVO all set to store future apps on the SD card. How do I force existing apps to the SD card? I have in particular that ‘move to SD card’ is not available.
do i need to root my htc wilfire s first to do this?
This is just what I’m after for my HTC Wildfire. However I don’t have Linux. Can I do this from my Windows 7 PC? Say, bring up a command window to do the .adb commands?
Hi,
I have Samsung galaxy ACE GT5830 mobile rooted version running android 2.3.4 Ginger bread. Will the above post works in android 2.3.4 also ? Please let me know.
hi
im experiencing a problem
i did this to my htc desire and it worked for a while then when i wanted to install an app i would hit install and after maybe 2 seconds it would say “application not installed”
if i use the sdk and set the installation path back to [0/auto] or [1/internal] the app can be installed
does anyone know how to fix this problem ???????
Very nice.
Helped a lot.
I can’t move these:
gmail
google maps updates
facebook
youtube
Is there a solution for these biggies?
rgds
Jan
Perfect. Exactly what I was looking for. This freed over 23 megs of internal storage space. Thank you very much, and long live Linux! Nexus One running Android 2.3.4.
PS. Google, you are awesome. But if you are going to put your name behind a phone with very limited internal storage, make your apps movable to SD. Seriously. It takes two lines of code.
@roberto: No this doesn’t require root.
@ Vijayendran Should be fine.
@Davide: Yes the same commands should work fine from windows.
When attempting to run these commands from command prompt in Windows XP, all commands yield error “permission denied” including the kill-server commands you recommended for those type errors. I am able to access the adb shell wherein the prompt changes from “c:\progra~1\android\android-sdk\platform tools” to a simple “$”. Any ideas on how to run this command or what command is required to gain sufficient permissions to make this change?
Ok i have a problem .. this worked but still the internal memory keeps on filling up.
thanks a lot bro
Followed all commands just fine. Restarted phone. Unistalled a couple different apps and reinstalled. They are still intalling on my phone and not SD card. Don’t know why it is not working. HTC Evo 4G.
I’m trying to do this, and have the phone plugged in. The sdk is downloaded but when I try
adb shell pm setInstallLocation 2 I get a device not found error. Am I missing something here? Hope you can help
@Alex: Bear in mind some apps will not allow installation to SD card whatever you do. Which apps were you trying to do this for?
@Chris: Is this on windows? If so this may help: http://code.google.com/p/android/issues/detail?id=1039#c10
Dear Stuart, sorry for bothering. My friend has asked to help with his son Galaxy mini with Froyo, as he is getting annoying message there is no space. I’m using Mac with Lion, have installed Android SDK and AVD Manager, downloaded Android SDK platform Tools. I’ve double clicked on android and terminal window + SDK MAnager app appeared. I’ve typed according to your guidance: ./adb shell pm setInstallLocation 2 (had to copy adb to the same folder as android (unit executable files) was stored. I got below stated messages:
lecho$ Downloads/android-sdk-mac_x86/tools/adb shell pm setInstallLocation 2
* daemon not running. starting it now on port 5037 *
* daemon started successfully *
Is it OK? Phone connected all the time.
Thanks in advance for your advice. Regards.
Lech
Macbook-Pro-3:~ lecho$@lecho: If you want to check if it’s set correctly just use:
<path-to-adb->/adb shell pm getInstallLocationcan i do dis in windows os ? i dont hav linux installed currently…
Hi, these directions worked perfectly for me. Thanks for taking the time to post them. One issue, when I restarted my phone all of the thumbnail icons for the apps I had moved to the SD card had changed to the default android thumbnail. Once I moved the apps back to the phone and restarted the icons were restored to their originals. Does anyone know why this is happening or how to properly move the icons along with the apps to the SD card?
Does this work on HTC wildfire s
My hTc wildfire s has the same problem!! very annoying…want to do this but cant understand how!! please help..
Very useful. Thank you.
I’m moving my apps right now, will post back if I see any problems.
Dear Sir,
I am using HTC SALSA with android version 2.3.3 (gingerbird) bought a week ago. The storage gets filled very often and unable to install anymore apps. I tried APP2SD app too and though its getting filled often.
I tried your steps and when I run the adb from the Platformtools folder , the command window just appears for a sec and then vanishes!! Can you please help !! I even tried running as Admin too and also tried running with the sdk manager open , but in vain. Please help me sort it out!!
Thank you, since going to 2.3.3 on my Desire I’ve been running out of space, this has really helped!
@Balaji Manoharan hi sounds like you need to use a terminal (linux) or the command prompt (windows) to run the commands in question.
If you’re using windows go “start” -> “run” and type cmd to get the command prompt. From there you’ll need to navigate to the adb tools directory e.g
cd \path\to\tools. Alternatively this “hack” makes life easier as you can right click from explorer and the command window will open in the right place. http://www.howtogeek.com/howto/windows-vista/make-command-prompt-here-always-display-for-folders-in-windows-vista/Note that if you’re using windows use
adbrather than./adbin each case.Hope that helps. Let me know if you’re still stuck.
@Rich: Thanks, I’m glad it’s useful.
Thanks Very Much Stuart.. I tried as you said. I right clicked on the window containing the adb application file and then , clicked on “open command window here” and then popped up a cmd window for that location and then I typed ” adb shell pm setInstallLocation 2″ and then hit ENTER and then nothing appeared! just again the same path of the CMD window appeared, is this right?
Thanks in advance!,
Balaji Manoharan
I get to the very last step, input adb blah blah blah and get
ERROR device not detected.
On my computer, it comes up on driver F
I can move music from my computer into my phone
I’ve done an update and computer says device is working properly
I have an Alcatel One Touch 908s
What gives?
@Balaji: Try checking it with “adb shell pm getInstallLocation”
@Freia: Have you enabled “USB Debugging” under settings -> applications -> Development?
Everything works great on my HTC Legend and also on Huawei Ideos S7. I love your work here !!! Thank you you save me with this thread.
Smide
I run the command…and it says device not found. I have the drivers installed for the phone. The computer beeps and recognizes it and in the phone notification tray it shows usb connection and usb debugging. WTF ?
P.S. I tried my LG Updater…and it finds my phone no problem. Do not know why I am getting the error mentioned above. Please Help !
@Pete: Is this windows? Can you try running
adb devicesI am running Windows 7.Pretty much a newbie to Android though. I am able to type ADB and it runs a bunch of stuff… but when I type adb shell…it keeps saying device not found. Again, when I use the LG Update tool…it connects no problem. It is a LG Optimus M. I just got an update not to long ago to 2.2.2. Can that be causing it. I don’t think so since it is supposed to work with even 2.3 ? Again any help would be appreciated. I am trying to free up internal memory.
Thanks.
@Pete: and did you run
adb devices? This will tell you if adb can see your phone. If you can do that and post the output it might help to solve the issue.Also you could check that USB storage is turned off.
How do I run adb devices…sorry…on very familiar with it. I did follow the instructions to a T…and got up to the part to type the command, but got that error message. Again, please let me know how to run adb devices and I will post the output.
lol…P.S. How do I check if USB storage if off ? Thanks for all you help and patience. I came along way believe it or not.
@pete: To check USB storage is off – it should say it’s connected as a drive on the phone when hooked up via USB. To check the status drag the top of the screen down to reveal the current status.
Now to get connected under Windows 7:
First step is to check USB debugging is enabled. On the device, go to Settings > Applications > Development and enable USB debugging.
On windows you need to have installed USB drivers if you haven’t already – this page lists the USB drivers for most phone hardware manufacturers: http://developer.android.com/sdk/oem-usb.html
Once you’ve downloaded the driver the install instructions are here: http://developer.android.com/sdk/win-usb.html#Win7
Once this is done it should just be a case of opening the command window ( In the Start Menu search box area type cmd and press Enter.) Navigate to where you installed the Android SDK and then to “platform-tools” and run
adb devices. If connected, you’ll see the device name listed as a “device.”Let me know if you get stuck at any point.
Thanks Stuart for all your help. On a whim, I downloaded another version of Android SDK and IT WORKED ! SUCCESS finally !!!!! Thanks again for you great post and answering me so quickly. If you have an email list and have updates or new ideas, please add me to it. Freed up so much memory !
Wait…in actuallity in only let me move two apps…is that normal. Like google maps….it won’t let me move it, facebook and a mail app it did ?
@Pete: Yes unfortunately some apps are authored in such a way that prevents moving them even with the install location updated.
One way to work around this is to root your phone and install CyanogenMod 7 and then use something like simple2ext which allows you to format your SD card and then it can use that for applications. I’ve recently done this on my Desire because whilst you can free some space with the install location method it’s really only a stop-gap measure.
Naturally this is all a bit more involved and is potentially more risky as you could brick your phone in the process.
My phone is an LG Optimus M. It just received an update not to long ago from froyo 2.2 to 2.2.2, That I know messed everyone’s root up etc… can that be causing my problem as well. When I enter adb shell I get a $ like other post say then pm InstallLocation 2 I get another $ dollar sign that many other posts say I should get. Then just reboot my phone and voila…well like I said, most of the Bloatware is still unable to be moved ? Please help.
Sorry for all the posts. It is letting move about 8-10 apps using APP2SD…but the Bloatware I am guessing that is installed my the manufacturer is just impossible to move, at least without rooting, which I had a “pro” try to root my phone and could not…was unable to downgrade back to 2.2 to attempt a root. Will have to wait til someone comes out with a new procedure. Really want Gingerbread if I can figure it out. Oh well, if you just let me know it is normal not to be able to move bloatware. From my reading, it is…and now with being able to move other apps that I couldn’t move before I am guessing that is just the case. Please confirm ?
@Pete: yes that’s correct – see my previous reply – some apps just can’t be moved with this technique.
As soon as they come out with a technique to root froyo 2.2.2 or I can figure out why I can not downgrade my phone to 2.2…I will definately try rooting again. Thanks for all your help. This little fix gave me about 35MB of free space. Considering my measley old MetroPCS LG Optimus came with 200MB total, I got a decent gain. Thanks again for your help. You’ve been outstanding !
I did have many problems along the way, but most of them were the same ones as the other people had. Since you answered all their questions, I had practically no problem doing this. My Xperia Play has only 200MB total for me to use, so this is wonderful. This gave me 50MB of free space, which was wonderful. Thank you so much for this!!!
Hi,
I’m still having “permission denied” problems. My device is a Wildfire S and OS is Win 7 Pro.
Hi,
Kindly ignore my previous comment. I’ve successfully completed it, it was just the wrong commands. Big Thank you!
On my HTC Wildfire S I was able to move some apps, eg. my Swiftkey input which is great. However, it still won’t let me move Facebook or Gmail apps… I can’t root since my phone is S-ON. Do you know of any way to move those big apps to the sd card as well?
Also, HTC and 3 have installed lots of small useless apps and widgets that I never use, do you know of any way to move these to the simcard?
Thanks for the clear explanations!
@Anne: Unfortunately pre-installed apps generally cannot be moved (which typically includes things like Gmail/facebook etc). If this is a problem then it’s probably worth looking into rooting your phone and then possibly installing something like Cyanogenmod 7.
I recently did this on my Desire and found the processes straight forward enough and with a EXT4 partition on a class10 SD card combined with simple2ext (cyanogenmod7 only) running out of space is a thing of the past. That said if you remotely consider rooting/reflashing *do* take care to back everything up and understand the risks inherent in these processes before you start.
Works great in my Samsung Ace. Without any errors. It allows me to move some apps to my SD card, stopping the boring message of lack space.
Thanks.
Thanks a lot. Brilliant…
I’ve been pleasantly surprised at how much I liked my Samsung Admire. The one downfall was the limited internal memory filling up so fast. This has been an ABSOLUTE lifesafer! You rock buddy! Thanks so much!!!!!!
- (set install location to sdcard on source device)
adb shell pm setInstallLocation 2
- (download app from Market on source device)
- (pull app off sdcard)
adb pull /mnt/asec/com.app.blah
pull: building file list…
pull: /mnt/asec/com.app.blah/pkg.apk -> ./pkg.apk
1 file pulled. 0 files skipped.
3220 KB/s (1983084 bytes in 0.601s)
- (hookup target device and install)
adb install pkg.apk
Hi all i have a problem when i open the adb it open very quickly and the close automatically so any one can help me
thanks
LG Optimus One P500 – works.
Had a little trouble finding the USB drivers though, THE ONES IN THE SDK WILL NOT WORK !!! But I found them easily on Google.
Didn’t help me as much though, yes, you can move many more apps on the SD, but some don’t work on SD, such as widgets and task killers… so it’s one thing to move them on external storage and a whole other thing to make them WORK on SD.
)
I just type de command to set location on SD Card, and work fine. Now i can move may apps to sd using app manager on my Android 2.3.4.
Phone: Samsung Galaxy ACE.
Thanks a lot.
hi stuart
will it work on windows? thanks in advance.
it works..but after moving apps to SD card still it acquires phone memory…
i installed ninja game of size 8mb than i moved it in SD card but my phone memory also reduced to 12mb from 20 mb..every apps i download it is installed in both sd card and phone..
any solution for it??
my cell is GALAXY pop mini
i own a mac and whenever i try the command “./adb shell pm setInstallLocation 2″ it says “-bash: ./abd: no such file or directory found…help please?
*edit* everything is working fine, but when I type the command adb shell pm setInstallLocation 2 it says its an unknown command…
Hi,
For people facing issues with no directory found, or no such commands using this code
./adb shell pm setInstallLocation 2Is not working because IMHO in the recent updated sdk the adb location has been changed and hence try using this
adb shell pm setInstallLocation 2Hope this solves the problem.
Thanks for the tips. It works on my Samsung Prevail. I haven’t try it on Samsung Galaxy Player 5.0 yet but I will later on. I need to get a bigger storage like (32GB) from a nearest store. I couldn’t wait, even though I supposed to receive a mail package from Amazon supposedly tomorrow.
After the mod on the default installation (0:auto) to 2:external, most of my apps are ready to be moved. I double check with different apps like SDMove, App2SD Free, and our default Android Application–>Manage applications,
If you’re using appSaver it will say “These Apps can’t be moved to SDcard”.. However, actually it will once you double tap on any app listed.. lol.. Thanks! Now I am worry free of the tiny 161.18 MB internal system storage partitioned on my Prevail. Hopefully it will work on m 2 GB internal system on my Samsung Galaxy Player 5.0 too.
I forgot to mention this, I am still using Froyo.. 2.2.
The applications that couldn’t be moved is as listed under SDMove:
1.Layar
2.Link2SD
3.MinaSoftIME
4.Poynt
5.SCVNGR”
6.Twidroyd
listed under App 2 SD Free
1. Market
2. YouTube
3. Link2SD
4. Street View
5. MinaSoftIME
Hi, very interesting post, very helpful, I own Htc wildfire S, do I have to put S-off to root the phone, if yes please tell how… Or shud sell off wildfire S & buy sensation or S2 …. I am scared to brick my phone …..
How do I subscribe to this post?
Hi, very interesting topic found thru google. Stuart I really appreciate your & other fellow member’s comments.
I am looking forward to a reply if anybody can guide me to turn the S-Off on Htc wildfire S the easy way, I am looking forward to root my phone.
I am scared to brick my phone, should I leave it d way it is n sell off n buy a sensation or S2 …. I really like my wildfire S…
Awaiting comments…
@Vishal: There’s a comments feed for this post here: http://muffinresearch.co.uk/archives/2011/02/02/android-force-moving-apps-to-an-sd-card/feed/ You can subscribe to that in any feed reader such as Google Reader.
To force moving android apps to the sdcard you don’t need root. However, if you find the limitations are too restrictive then you can use something like unrevoked (just google it) to unlock your wildfire. If you are at all worried about it after reading the instructions then I’d suggest not doing it. It goes without saying really that rooting your phone is risky and should be carried out if you understand the risks you are taking.
After reading through all the comments, I think I just want to point out two things to people going through this process. 1. If your “adb” command isn’t working, you might need to execute it from a different folder. 2. If adb is working and you’re getting device not found, it could be a usb driver issue even if your usb driver has worked before. My USB driver was up to date, all the debugging, etc., was checked off appropriately, but it needed a different driver to work with Android. Windows would not find it through their search, a google search and manual update through device manager worked.
Personally, I am now stuck on the install location command not working. Thinking like you said, things may have moved.
Thank you for posting the commands so clearly above!
On to more googling…
@fivekitten: This post was originally written with linux users in mind however if you’re using windows you can drop the “./” and use “adb” and the command should work. The “./” is a linux idiom.
Thanks a lot Mr for your useful tutorial
, I have a question:
I’ve installed the package specified for linux -using ubuntu- but when it’s extracted I can’t find “adb” file in tools nor in platforms :’(…..is it possible because JDK not installed or something missed ??
@wisdom: Currently if you download and extract the sdk you’ll need to run
./androidwhich will open a window with an option to download platform-tools. Once you’ve downloaded and installed that you should find adb there.Great….that’s done perfectly with “Galaxy mini”
, but still something confuses me ! even I moved all apps to SD card the internal storage deceased just about 30 MB !! how is it eaten ?!!
@wisdom: This method helps, but cannot move everything to the SD card. This is a known limitation. If you really want to fully utilise the SD card for apps then there are other alternatives out there but you’ll need to root your phone.
In the end I found the technique detailed in this post helped initially with preventing the out of space messages on my htc desire. However it only put off the inevitable.
I have since rooted my phone and installed Cyanogenmod along with a 16GB Class 10 SD card utilising simple2ext. Now I have bags of space and performance is fine. However clearly carrying out these steps does not come without risks.
sorry for many questions but I don’t know how to thank you for your help
, Now I get a lot of free internal memory by factory reset my phone then do instructions above to install apps on SD card….my last question is : is it kind of risk if I left default apps installation on SD card ?? I did that and re-install all my apps without any wrong error !
@wisdom: Not sure is the honest answer. Off the top of my head I doubt you’ll see a problem – it will just use up some SD card space.
I can connect my phone and get the adb shell but no matter what I try the adb command will only run as the shell user so I cannot execute the pm command. I can kill the server using the kill-server command but since I am connected using a Windows 7 machine I cannot use the sudo command. I try executing adb root but when I go back in the shell it is not running as root.
This is the second phone I am executing this on and I did not have this issue before.
Thanks
Worked like a charm on my Nexus One (Android 2.3.4). Although FB, Gmail etc. won’t move, I was still able to free up 16 MB. Thanks Stuart!