Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Programmatically determine if a microSD card has been inserted

by Retired ‎02-12-2010 03:05 PM - edited ‎09-16-2010 03:08 PM (5,835 Views)



This article applies to the following:

  • BlackBerry® Device Software 4.2 and later



The BlackBerry® Pearl™ 8100 smartphone was the first BlackBerry smartphone to support microSD cards. Along with microSD card support, the BlackBerry Pearl 8100 smartphone was the first BlackBerry smartphone to support Java Specification Request (JSR) 75, the FileConnection application programing interface (API). In addition to providing the ability to store data to the internal memory and microSD card, this API also allows an application developer to determine if a microSD card has been inserted into the BlackBerry Pearl 8100 smartphone.



String root = null;
Enumeration e = FileSystemRegistry.listRoots();
while (e.hasMoreElements()) {
     root = (String) e.nextElement();
     if( root.equalsIgnoreCase(“sdcard/”) ) {
        //device has a microSD inserted
     } else if( root.equalsIgnoreCase(“store/”) ) {
        //internal memory identifier


The previous code will allow a developer to determine if a microSD card is currently inserted, while the following code will notify the developer if this state ever changes (card removed/card inserted). Note that the listener must be added to FileSystemRegistry via the addFileSystemListener() method.



public class MySDListener implements FileSystemListener {
       public void rootChanged(int state, String rootName) {
              if( state == ROOT_ADDED ) {
                  if( rootName.equalsIgnoreCase(“sdcard/”) ) {
                        //microSD card inserted
              } else if( state == ROOT_REMOVED ) {
                  //perform the same check as above


As of the last updated date of this article, an API did not exist to determine if the BlackBerry smartphone could support microSD regardless of whether or not a card was inserted. However, the BlackBerry smartphone model number can be used to determine microSD card support, as in the follwoing code, since the list of BlackBerry smartphones that support this feature is finite.



String modelNum = DeviceInfo.getDeviceName();
if ((modelNum.startsWith("8") && !modelNum.startsWith("87")) || modelNum.startsWith("9")) {
        //microSD card supported


Users Online
Currently online: 36 members 2,964 guests
Please welcome our newest community members: