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

Posts: 211
Registered: ‎04-29-2009
My Device: Not Specified
Accepted Solution

Read file stored on sdcard while debugging an application


I am trying to record a wav file and save it on sdcard of device. Im using Pearl with 4.5 OS.

Whenever I debug the application on real device, I am not able to read the file or even write file to sdcard...

How I can read and write files on sdcard? 

Posts: 289
Registered: ‎10-17-2008
My Device: Torch 9800
My Carrier: Rogers

Re: Read file stored on sdcard while debugging an application

Hi tejaswini,


It would be helpful if you posted the code you are currently using to try to read/write.


FileConnection fconn = (FileConnection)Connector.open("file:///SDCard/BlackBerry/documents/data.dat");

if (fconn.exists())


  DataInputStream disRead = fconn.openDataInputStream();



    int iData = disRead.read();


  catch (IOException ioe)


  // exception handling 




For further information, look up the FileConnection, DataInputStream, and DataOutputStream classes in the API library.


If your issue is solved, set "Solution" mark at the relevant post.
Don't hesitate to Kudos people whose posts helped you.


feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
Posts: 283
Registered: ‎07-22-2008
My Device: Not Specified

Re: Read file stored on sdcard while debugging an application

It looks like you have the Mass Storage Mode on when you connect via USB.

So make sure that it is not the case:


go to the device options-->Media Card  and set " Auto Enable Mass Storage Mode When Connected" to "No", or to Prompt.

If you set it to prompt, it will ask you when you connect the device, and you should answer NO.


Make sure that you the device is not connected to USB when you set it.