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: 82
Registered: ‎12-16-2010
My Device: BlackBerry Storm 9950
Accepted Solution

Files will not delete off of SD card through FileConnection

As a part of the App that is being developed we are trying to make the files dynamic.

 

When running through the update code we are plucking out the files that are out of date and trying to update them by first deleting them and then downloading them again.  Here is the code we are attempting to use

 

try
        				    {
            					conn2 = (FileConnection) Connector.open("file:///SDCard/MeetApp" + filename.substring(0,(filename.length()-1)) + ".xml", Connector.READ);
        				  
        				                                
        				                                       if (conn2.exists())
        				                                    {System.out.println(conn2.fileSize());
        				                                              conn2.close();
        				                                         conn2 = (FileConnection) Connector.open("file:///SDCard/MeetApp" + filename.substring(0,(filename.length()-1)) + ".xml",Connector.READ_WRITE);                                                      
        				                                               conn2.delete();
        				                                               conn2.close();
        				                                        }else{System.out.println("No dice");}
        				}
        				catch(Exception e)
        				{
        					
        				}          	

 

 

 

However, the files won't delete.  I have triple checked the pathnames, they are correct.  However, everytime I ask it to find a file it says that it doesn't exist.

 

Any ideas?

 

 

Developer
Posts: 254
Registered: ‎03-15-2011
My Device: simulator
My Carrier: simulator

Re: Files will not delete off of SD card through FileConnection

Is MeetApp a folder in SDCard? If yes, add a slash "/" in file connection as "file:///SDCard/MeetApp/"

 

and try running your app.

 

 

 

------------------------------------------------------------------------------------------------
Click "Accept as Solution" if post was what you needed. Give kudos if you feel response is helpful.

Developer
Posts: 82
Registered: ‎12-16-2010
My Device: BlackBerry Storm 9950

Re: Files will not delete off of SD card through FileConnection

I found the issue.  When I parse the type of file out of an XML document I get the word "page" or "asset".  There must be a space on either side of those words when they come from the XML document because they don't equal the String "page" unless you trim() them.  To be sure I converted them to hashcode and now it works properly.