Can't Burn to Micro SDCard on BlackBerry

I am trying to save some files to micro sdcard. To check SDCard availability, I use the following method:

private boolean isSdCardReady() { Enumeration e = FileSystemRegistry.listRoots(); while (e.hasMoreElements()) { if (e.nextElement().toString().equalsIgnoreCase("sdcard/")) { return true; } } return false; } 

Even if this method returns true when I try to save the files, it net.rim.device.api.io.file.FileIOException: File system is not ready exception.

What does it mean? If the SDCard is not available, then why is it listed in FileSystemRegistry.listRoots() ?

How can I make sure SDCard is writable?

My development environment:

  • BlackBerry JDE Eclipse Plugin 1.5.0
  • BlackBerry OS 4.5
  • BlackBerry Bold with a 3G card.
+4
source share
2 answers

Solved a problem. I searched for "sdcard", and rootsEnum.nextElement().toString(); returns "sdcard". Yes, its case is case sensitive. Now, instead of using the hard-coded "SDCard", I changed the above method to the following:

 private static String getSdCardRootDir() { Enumeration rootsEnum = FileSystemRegistry.listRoots(); while (rootsEnum.hasMoreElements()) { String rootDir = rootsEnum.nextElement().toString(); if (rootDir.equalsIgnoreCase("sdcard/")) { return "file:///" + rootDir; } } return null; } 

Using this, I got the root directory in the system specific case.

+2
source
  • I usually had this error when I tried to access the SD card when rebooting the device. You must defer all operations in the application until the launch is complete:

     while (ApplicationManager.getApplicationManager().inStartup()) { try { Thread.sleep(500); } catch (InterruptedException ignored) { } } 
  • I remember another possible reason mentioned here . You must close all threads after use.

+3
source

All Articles