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

Java Development

Reply
Trusted Contributor
Posts: 130
Registered: ‎08-10-2010
My Device: Not Specified

Re: File I/O on local

Hi Peter,

 

Would you please explain what do you mean by "hey don't have anything else in the same place"?

 

After I choosing a location for SD card, there would be directories like 'audiobooks', 'documents' , 'music' etc.

 

Do you mean in such situation the writing file action doesn't work?

Trusted Contributor
Posts: 130
Registered: ‎08-10-2010
My Device: Not Specified

Re: File I/O on local

Problem solved.

 

Seems it doesn't work because I set my app as auto-run on startup. At that point, the SDCard is not inserted yet. It needs a while for the SDCard to load.

Highlighted
New Contributor
Posts: 3
Registered: ‎06-12-2011
My Device: bold-9000
My Carrier: sk-telecom

Re: File I/O on local

 

The follwing code that is about writes files is from my app and is just a part of whole codes.

So u need to make other codes with blow codes. (i.e. try-catch things and make approprite variables things)

 

---

                      FileConnection fc = (FileConnection)Connector.open(protocol + filePath + fileName);
                      if (!fc.exists())
                       {
                            fc.create();  // create the file if it doesn't exist
                       }
                       OutputStream outStream = fc.openOutputStream(); 
                       outStream.write(strFileContent.getBytes());
                        
                       outStream.close();
                       fc.close();

 

--

 

My variable "protocol" is "file://" and filePath is "/SDCard/BlackBerry/"

The above codes can be the answer for u maybe.

 

thanks!