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
Developer
Posts: 42
Registered: ‎03-03-2009
My Device: 9600
My Carrier: Vodafone
Accepted Solution

Can't able to create Custom Folder in SDCard (Memory card) for storing images into it.

Hi All,

          I have successfully create one folder (my custom folder) into blackberry inbuild media picture folder.

 

         But when i am trying to create same folder in memorycard (SDCard) then it doesn't create the folder.

 

         I am working on 8520 simulator with 4.7 JDE. Below is my code sample 

 

         1) for creating folder (Tej /tejas.bmp) into  Inbuilt Picture media ( Successfully created ): -

 

        try {
                  
                        FileConnection file = (FileConnection) Connector.open(System.getProperty("fileconn.dir.photos")+ "Tej/tejas.bmp",Connector.READ_WRITE);
                            while (file.exists()) {
                                   file.close();
                            }
                        file.create();
                        out = file.openOutputStream();
                      
                        // Close the connections.
                        out.write(data,0,data.length);
                        out.close();
                       
                        file.close();
                      
                        System.out.println("File Write Successfully");
                   
                    } catch (Exception e) {
                        System.out.println("Exception in FileConnection Write:"+e.getMessage());
                    }

 

             2) for creating folder (Tej /tejas.bmp) into  MemoryCard (SDCard) Picture media (Not able to creat ): -

 

               try {
                  
                         FileConnection file = (FileConnection) Connector.open(System.getProperty("fileconn.dir.memorycard.photos")+ "Tej/tejas.bmp",Connector.READ_WRITE);


                            while (file.exists()) {
                                   file.close();
                            }
                        file.create();
                        out = file.openOutputStream();
                      
                        // Close the connections.
                        out.write(data,0,data.length);
                        out.close();
                       
                        file.close();
                      
                        System.out.println("File Write Successfully");
                   
                    } catch (Exception e) {
                        System.out.println("Exception in FileConnection Write:"+e.getMessage());
                    }

 

          Please give any code reference if i am wrong in  2nd case . Otherwise tell me if any setting needs to be done to create folder into sdcard (in this case , i am using my PC as SDCard ).

Tejas Barbhaya

Logistic Infotech
tej.barbhaya@gmail.com
www.logisticinfotech.com
Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: Can't able to create Custom Folder in SDCard (Memory card) for storing images into it.

[ Edited ]

Can you post questions like thi sin the java forum:

http://supportforums.blackberry.com/t5/Java-Development/bd-p/java_dev

 

Can you please dump out the file name generated when you write to the SDCard, for example change

 

FileConnection file = (FileConnection) Connector.open(System.getProperty("fileconn.dir.memorycard.photos")+ "Tej/tejas.bmp",Connector.READ_WRITE);

 

to

 

String fileName = System.getProperty("fileconn.dir.memorycard.photos")+ "Tej/tejas.bmp";

System.out.println("SDCARD File Name: " + fileName );

FileConnection file = (FileConnection) Connector.open(fileName,Connector.READ_WRITE);

 

Could you also please give us the text of the Exception that you see, i.e. the output from:

System.out.println("Exception in FileConnection Write:"+e.getMessage());

 

Cheers

Developer
Posts: 42
Registered: ‎03-03-2009
My Device: 9600
My Carrier: Vodafone

Re: Can't able to create Custom Folder in SDCard (Memory card) for storing images into it.

Hi ,

      I am getting exception like "File System Error"

 

Thanks,

Tej

Tejas Barbhaya

Logistic Infotech
tej.barbhaya@gmail.com
www.logisticinfotech.com
Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: Can't able to create Custom Folder in SDCard (Memory card) for storing images into it.

There are a number of Threads on this forum that talk about that Exception.  Can I suggest you review these to see if any of them is applicable?

Highlighted
Developer
Posts: 42
Registered: ‎03-03-2009
My Device: 9600
My Carrier: Vodafone

Re: Can't able to create Custom Folder in SDCard (Memory card) for storing images into it.

Thanks after searching a lot , i got that it will work in device but not in simulator and fortunatelly it correct.

Tejas Barbhaya

Logistic Infotech
tej.barbhaya@gmail.com
www.logisticinfotech.com