[Guide] Android 2.2 App Storage vs. Apps2SD – What are the benefits?

As a refresher, I wrote an article earlier briefly covering the built-in app storage method used by Android 2.2 (known as Froyo), which differed from the methods that 3rd-parties were implementing app storage via Apps2SD. Having run into some issues recently with the Froyo method, I investigated further and reverted back to the Apps2SD method. Here’s a rundown and further detail of what I discovered about the way Android stores programs.

Why is this even necessary?

In short, more programs and bigger programs. If you have many apps, or multimedia apps (such as games), or large apps (such as Google Earth), your internal storage will run out sooner or later. This is one of the drawbacks of having removable SD cards. Froyo brings a way for users to store apps on their microSD card, however in doing so, they had to fulfil a number of criteria for this to be successful (these are just my thoughts):

  • It has to be seamless, not requiring end-user configuration to avoid confusion.
  • It has to be effective, not throwing errors if the application is located on either medium.
  • It also has to be controllable, giving more advanced users the ability to control where apps are stored.
  • It has to be flexible, in the event the user removes the SD card for one reason or another.

The truth is, no matter how well it’s implemented, things are bound to get ugly. This is one of the biggest issues that requires addressing in Android, that there is not a contiguous requirement of space on the hardware. Such an situation exists because of the variations in hardware amongst handset makers. There is also an additional problem: the SD card only initialises after the phone boots, and the SD card becomes inaccessible to the system when mounted to a PC via USB. This means critical system applications cannot be stored on the SD card.

So how does Android 2.2 address this?

First of all, 2.2 allows developers to specify where their application should be installed. Applications which developers know are critical (here is a list of applications which are marked as crucial)  and must be stored internally can be forced via the android:InstallLocation parameter. Alternatively, a setting of ‘auto’ means there is no preference, leaving it to the handset to decide which one is best.

Applications on the SD card are stored in an encrypted form in the .androidsecure folder (instead of the /data/app or /system/app of the internal memory). The period at the beginning of the folder name is a naming convention to signify hidden folders. A randomly generated key is used to encrypt the file, which can only be decrypted on that particular device, for anti-piracy reasons. In addition, any data files, program cache and settings, are still kept on the internal memory.

I’ve used this system, for most part it works fine. At times I still visited the Applications panel to manually move things to the external storage as required, or move them back into the internal memory if they were present on the home screen or widget form (or else it would not initialise correctly on phone boot, leading to a default icon).

If you are running 2.2 and you want to manually control where new applications are installed, check out ModInstallLocation, which lets you specify this variable manually (auto, internal, external), root required. You can thus override developer preferences to where the app is located.

What problems does this method have?

You can see that this is a fragile system, there are going to be situations where widgets don’t load properly, programs have strange icons, because the SD card was offline at the time. For many people, this may be confusing or frustrating, as there isn’t much in the way of explanations once this happens. In addition, I still ran into low disk space warnings, even having moved nearly all programs to the SD card. For 80% of the public, I’m sure they will have no problems however.

In addition, once you connect your phone to your PC and mount the SD card, the card becomes inaccessible to the phone. This method is the most common way people connect to their phones, but more advanced users will use ADB, or a wireless SMB/FTP/HTTP since it’s more flexible. This means that any programs stored on the card shut down and become inaccessible, quite an inconvenience, especially if it’s a background task. Another issue arises, in the standard Application manager, there is no icon indicating that a program is stored on internal memory, which means manually pressing on each one to see if you can move it to SD card. Tedious and unnecessary.

What’s the alternative?

Eventually, I got sick of micro-managing applications (I tend to store quite a few) and looked into alternatives. If you have a rooted phone, ‘apps2sd’ is definitely one of the most popular and effective methods used. In short, it redirects applications when installed to the phone memory, to store it in a specialised partition on the sdcard. As far as the OS is concerned, it’s storing files internally. Functionality is not affected, you can mount/unmount the card and it doesn’t interfere with this partition at all (because it isn’t accessible from the PC or the phone normally). Independent and effective storage, the way it should be.

In addition, under some implementations of A2SD, you can move the Dalvik cache to the SD card, which frees up valuable ROM space, as well as automatically zipaligning packages. Some will also allow you to utilise a swap file partition on the SD card for virtual memory, although this is mostly obsolete in today’s phones with huge amounts of RAM.

There are requirements:

  • A class 4 SD card or higher
  • Rooted phone with Recovery console accessible
  • An ext2/3/4 (depending on which ROM you’re using) partition on the SD card, you can create/format this via Recovery console (I’ve set mine to 1GB, of which I’ve only used 226MB see below)

Steps required (thanks to DarkTremor):

  • Backup your SDcard to your computer. Partitioning will wipe the entire card.
  • Reboot into recovery
  • In android system recovery, select partition sdcard
  • In the partition sdcard menu, select partition sd
  • Follow the instructions on the phone to partition your sd card. You can optionally set a swap file while you are partitioning your sd card.
  • In the partition sdcard menu, select sd:ext2 to ext3. Follow the instructions on the screen.
  • only perform this step if you want ext4 and your rom supports it: in the partition sdcard menu, select sd:ext3 to ext4. Follow the instructions on the sdcard.
  • Press the back button on the phone to go back to the main menu.
  • Put the a2sd file on the sd card (and all your other files you backed up earlier) by selecting usb-ms toggle and transfer the files to your computer.
  • In recovery, select flash zip from sdcard.
  • In flash zip from sdcard, select the a2sd package file you downloaded earlier. Press home to flash.
  • Reboot phone.

See here and here for more information on apps2sd.

Does it work better?

Yes, by a long way. As far as seamless storage of applications to SD card goes, it’s a much more elegant solution to the issue than Froyo’s method, there are no abnormal behaviours or restrictions on what types of applications can be stored on the SD card. Everything just works, and it works all the time, no matter what the phone is doing. There is only one situation in which issues would arise, that is if the SD card is physically ejected, however the core applications such as the phone/SMS/etc will still function as these are stored internally regardless. There is no noticeable performance difference or slowdowns when running applications from the SD.

Note that if you are running Froyo and have a mixture of apps stored internally and on SD card, all internal apps will be moved to SD card by A2SD automatically. Then use the built-in application manager to move apps back ‘to phone’, which in fact moves it to the A2SD partition. For all intents and purposes, the phone thinks everything is being stored on the phone, it’s just redirected.

UPDATE: For the technical nitty-gritty on Froyo SD Card storage, see here: http://android-developers.blogspot.com/2010/07/apps-on-sd-card-details.html



3 thoughts on “[Guide] Android 2.2 App Storage vs. Apps2SD – What are the benefits?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s