Smartphone devs, yes SD card speed matters!

If you want to get the highest performance out of your SD cards then read on. The purpose of this article is to raise awareness and spark your curiosity about SD card performance considerations.

Micro SD Class 2

Many developers I talk to aren’t aware that the read/write speeds of SD memory cards can have a significant affect on performance. This is especially true if you are moving around lots of data between a smartphone and the SD card. The good news is there is quite a bit of information out there to help you maximize performance, and a lot of it comes from high-end, camera aficionados believe it or not.

The most common feedback I get is developers typically buy cards with the most capacity at the lowest price. Depending on what you are doing, cheapest and slower isn’t always better. With little bit of research your read/write performance could get significantly better.

To start with there are four common speed classes: 2, 4, 6 and 10 and they represent an approximate minimum performance rating. You can find this number on the front of your card:

  • Class 2 ~ 2 Mbytes/sec
  • Class 4 ~ 4 Mbytes/sec
  • Class 6 ~ 6 Mbytes/sec
  • Class 10 ~ 10 Mbytes/sec

Read/write performance to your phones SD card really depends on HOW your application reads and writes data. You may have to do some testing to find out what works best. It depends on the consideration of multiple factors including:

  • Typical file types (e.g. video vs. text vs. image, etc)
  • Average file or data transaction size
  • Percentage of reads to writes
  • Duty cycle (percentage of reads or writes over a fixed time period)
  • Usage pattern

Usage pattern deserves a bit more attention and really starts to tell the story of what your application does behind-the-scenes. I think the best way to describe it is through some common use cases:

  • Many small reads and writes to/from a local database.
  • Occasional small reads and writes to local database.
  • Occasional large reads from local database.
  • Occasional large reads and writes to/from local database.
  • Large read upon application startup and large write upon application shutdown.

Wikipedia has noted that speed can differ significantly depending on what you are writing to the card. The article notes that writing large files versus writing many small files has widely different affects on performance. I’d seen similar observations when I worked on ultra-high performance server systems. So, the concept still remains today and provides excellent hints on how to tweak every extra millisecond of user experience.

If you need maximum performance then consider reformatting or defragging your card on a regular basis. I know Windows disk defragmenter utilities work on most SD cards, not sure about Mac. I have also seen multiple articles talk about bigger capacity is better because of memory fragmentation. With memory fragmentation, the card speed starts to decrease over time as the data becomes more fragmented. It’s the same concept as when you “defrag” the hard drive on your laptop.

References

If you want to learn more here are some helpful links:

SD Association – Bus speed

SD Association – Speed Class

Wikipedia – Secure Digital (See Speed Class Rating section)

Does your camera need a fast SD card? (good insight into SD card speed)

Running Android Apps Using External Storage (SD Card)

Hidden in the depths of the Android docs is an important chapter about info you need to know for running your apps off an external storage card. Here’s the link if you are a developer where you can use Manifest file settings so that anytime your app is installed it will be enabled for use on your SD Card: https://developer.android.com/guide/appendix/install-location.html . If you aren’t a developer then I can’t help you much because these settings require access to either the application source code, or the Android Debug Bridge.

You can also enable your apps for external storage from the adb command line using adb shell pm setInstallLocation 2. See the screenshot below. Once you’ve done that then use the adb install /mydir/some.apk to push the app to the phone. If the app isn’t automatically pushed to the card, then you’ll have to go into your droids application manager, select your application name, and then select “Move to SD”.

If you move the app to the external card you can find it using the built-in Android file browser under /mnt/asec/…

Here’s a quick link to Android dev docs on writing to internal and external storage. And, should you so desire to create a database on an external card you would point the SQLiteDatabase.openDatabase method to the appropriate directory path. I’ll point out that external storage is inherently insecure and you wouldn’t want to store passwords or anything important on it.

I’ll also add that not all storage cards are equal and some are much, much slower than others. Do your research, especially if you have a large application and you want snappy startup or read/write performance.