Android tips

Are you frustrated by the lack of memory on your Android device, or by its slowness, or short battery life? The following tips may help you. With these I have over 75 installed apps (several of them over 1 MB each) and still have 15 MB free. My phone is much more responsive, and the battery lasts between 1 and 2 days depending on use.
make it fast
make it last
make it vast

Disable wifi and bluetooth

Install the free WiFi OnOff widget. After installing from the Android Market, do a long press on your home screen, select "Widgets" then "WiFi OnOff". Enable wifi only when you actually need it.

To make sure you don't forget to disable wifi when there is no wifi signal, install wifi status. You do not have to run this app, it works as soon as it is installed.

Disable also bluetooth when you don't need it.

You can also disable GPS but this is much less important since the battery is drained only when an application such as Google Maps effectively uses the GPS.

Disable sync

During syncing my G1 is very unresponsive, hardly usable. So I keep sync disabled by default, and I enable it manually with AutoSync OnOff when I know I won't need the phone for the next few minutes.

Sync only your own calendar

Open Calendar, select Menu->More->My calendars->Menu->Remove calendars. Select all calendars except your own and click OK. This can save a lot of memory, but also makes syncing much faster. Do not just disable the other calendars, you must actually remove them.

Sync only your inbox

I do not use the GMail app on my phone because it's not manageable when receiving several hundred messages per day. But if you do use the GMail app, sync only your inbox, not all your labels. Open the GMail app, select Menu->Settings->Labels. Sync the mimimum number of days and of labels.

Disable the on-screen keyboard

Disable the on-screen keyboard in Settings->Locale & text->Android keyboard. This makes the phone much more responsive. Obviously this is possible only if you have a real keyboard, as on the G1.

Reduce screen brightness

Install the free Brightness Level widget. (See wifi above for widget install.)

Kill unused processes

Install TasKiller and kill the processes you do not need. Android kills processes automatically when RAM becomes low but this is generally too late, the phone is already slow.


If you run out of memory or your phone gets very unresponsive, try rebooting (long press on the red phone key).

Move stuff to /cache or SD card (for experts only)

The above sections are perfectly safe. If you still run out of memory, you need to get root on your Android device to be able to free a lot more memory by moving stuff to /cache or to the SD card. Do this only if you have enough Linux expertise. You can brick your phone if you make mistakes.

The simplest way to get root is to install a custom ROM. Search for android rooting to find many tutorials, including a video for 1-click install. However I personally prefer a much less intrusive method, which requires more manual work and Linux expertise, but makes minimum changes to the system instead of replacing it completely.

Get command line tools

Download and install the Android SDK to get adb. If you are using Windows, download and install the USB drivers.

Then install busybox on your phone. This gives you many useful command line tools and a better shell (ash).

Get root

If you have an ADP1 (Android DevPhone 1) you can install this kernel update, which contains the desired /system/bin/su. If you have another phone you will have to follow one of the rooting tutorials mentioned above.

The OTAs (Over The Air system upgrade) may disable root. To make sure you won't receive and install one by accident you can disable Background Data in Settings->Data synchronization. But you have to enable it temporarily whenever you want to use the Market app.

Cleanup /data/dalvik-cache

If you run out of memory, try first to remove everything in /data/dalvik-cache then reboot immediately. The necessary .dex files will be recreated automatically. I had about 15 MB of old unnecessary .dex files.

Move other data to the SD card

Applications often keep a large cache under /data/data/. Unfortunately many of them do not provide a way to clear the cache without clearing at the same the configuration parameters for the app. (You can clear the whole data in Settings->Applications->Manage applications.) You can find which applications use most space with:
  du -sk /data/data/* | sort -rn | head 
then move the biggest caches to the SD card as in the following example:
  cd /data/data/
  rm -R cache
  mkdir /sdcard/cache/market
  ln -s /sdcard/cache/market cache
Moving stuff to the SD card is unsafe since all apps can read and write its contents. So only non-sensitive data should be moved there.

Delete old system apps

If you have already upgraded Google Maps from the Market, you can delete /system/app/Maps.apk and /data/dalvik-cache/system@app@Maps.apk@classes.dex since the new version uses different file names. You must remount /system rw as shown below to be able to delete stuff from /system/app. Be very careful when modifying /system, you can break your phone. Don't forget to remount it ro afterwards.

Move .so files to /cache

/cache is used for OTA updates. But if you don't want OTAs you can move some stuff from /data to /cache, because /data is generally full and /cache generally empty. I do this for .so files which can't be put on the FAT32 SD card, such as the code of the nice Armadillo Roll 3D game. I run once:
  cd /data/data/com.qualcomm.qx.dillo/lib
  mkdir -p /cache/lib
  cp -p /cache/lib/
  chown 1000:1000 /cache/lib/
  chmod 444 /cache/lib/
  chmod 555 /cache/lib
  ln -sf /cache/lib/ .
then once and at each reboot:
  chmod 771 /cache
Do this only for games, not for essential system apps, because /cache might be cleaned by an OTA, and the access rights on /cache are reset to 770 at each reboot.

Move the apps cache to /cache

Most of the data space is taken by the apps cache /data/dalvik-cache. If you are still running out of memory after cleaning this directory and rebooting, you can move the dalvik cache to /cache/dalvik-cache. However this only works if /cache/dalvik-cache has 771 access rights but each reboot resets them to 770. (If you don't know what 771 and 770 mean, this section is too dangerous for you, please skip it.) So you need to run a script early in the reboot phase to change the access rights back. (Details ommitted: you must do this only if you're desperate and you have already applied all other methods to save memory.)

This removes the need for a special ext2 partition on the SD card, but it prevents OTAs which need /cache.

Command line editing

To get command line editing and automatic execution of .profile on the phone I use a rather indirect method, inspired from this blog. (There might be a simpler solution but I have not found it yet). On the phone I did once:
  mount -o remount,rw /dev/block/mtdblock3 /system
  echo 'root:xxx:0:0:root:/data/root:/system/bb/ash' > /etc/passwd
  ln -s /data/root/.profile /etc/profile
  echo root::0: > /etc/group
  touch /etc/shadow
  passwd root
  chmod 4755 /system/bb/su
  mount -o remount,ro /dev/block/mtdblock3 /system
with the appropriate hashed password instead of xxx. /data is mounted with the nosuid option, so I had to put a setuid copy of busybox in /system/bb/su.

I can now put arbitrary commands in /data/root/.profile without having to remount /system in rw mode, such as:

  export PATH=/data/bb:/data/root:/sbin:/system/bin
  export HOME=/data/root
  PS1='# '
  alias cp='cp -p'

Then on my laptop I run the following script:

  adb -d forward tcp:4444 tcp:23
  adb -d shell "exec /data/bb/telnetd -F -b -l /data/bb/login" &
  sleep 1
  telnet localhost 4444
  adb kill-server
The tab key and the arrows keys then magically work. Note that the password typed in telnet goes over the USB cable only, not over ethernet.

If I need root in the Terminal Emulator I just have to type

  /system/bb/su -
The tab key and the trackball work. I get the correct PATH and aliases, and also the correct uid (0 for root). The original /system/bin/su doesn't give the correct uid even when installed setuid root.

Do not forget to disable Settings->Applications->Development->USB debugging once you have finished otherwise someone else can get root access if you lose your phone and adbd runs as root.

Useful apps

Once you have made your phone responsive and saved a lot of memory, you can install the following apps that I found useful (more to come).

Back to Jean-loup's home page.