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. New to the forum? Please visit the ‘Getting Started’ link below.
inside custom component

Java Development

Reply
Trusted Contributor
babyblue_lee
Posts: 130
Registered: ‎08-10-2010

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?

Please use plain text.
Trusted Contributor
babyblue_lee
Posts: 130
Registered: ‎08-10-2010

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.

Please use plain text.
New Contributor
greesp
Posts: 3
Registered: ‎06-12-2011
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!

 

Please use plain text.