Welcome!

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

Web and WebWorks Development

Reply
New Developer
yugandhar_pathi
Posts: 11
Registered: ‎11-22-2012
My Device: Bold 9900
My Carrier: Aircel

How to detect if memory card is present in the device slot or not?

Experts!!

Is there a way to detect if memory card is present in the device slot or not?

I observed that native camera application is somehow detecting this!!

 

I tried using FileSystemRegistry.listRoots() API .

This API will return current available roots on the device.

Problem is when i connect device to PC in USB Drive mode.API is returning only "system/" root becuase memory card is unmounted.

 

So i cannot rely on this API!!! Please help !!

Please use plain text.
Developer
DirkLuys
Posts: 123
Registered: ‎02-13-2012
My Device: Z10 LE
My Carrier: Mobistar

Re: How to detect if memory card is present in the device slot or not?

I found this code somwere in the support forums, It looks pretty decent to me.

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

 ----------------------------------------------------------------------
Press the  button to give kudos if I helped you :smileyhappy:

Please click the like button if my post helped you! Thank you.
Please use plain text.