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


Thank you for visiting the BlackBerry Support Community Forums.

BlackBerry will be closing the BlackBerry Support Community Forums Device Forums on April 1st (Developers, see below)

BlackBerry remains committed to providing excellent customer support to our customers. We are delighted to direct you to the CrackBerry Forums, a well-established and thorough support channel, for continued BlackBerry support. Please visit http://forums.crackberry.com or http://crackberry.com/ask. You can also continue to visit BlackBerry Support or the BlackBerry Knowledge Base for official support options available for your BlackBerry Smartphone.

"When we launched CrackBerry.com 10 years ago, we set out to make it a fun and useful destination where BlackBerry Smartphone owners could share their excitement and learn to unleash the full potential of their BlackBerry. A decade later, the CrackBerry community is as active and passionate as ever and I know our knowledgeable members and volunteers will be excited to welcome and assist more BlackBerry owners with their questions."

- Kevin Michaluk, Founder, CrackBerry.com

Developers, for more information about the BlackBerry Developer Community please review Join the Conversation on the BlackBerry Developer Community Forums found on Inside BlackBerry.


Reply
Developer
Posts: 298
Registered: ‎05-02-2010
My Device: Bold 9700
My Carrier: Verizon
Accepted Solution

Deleting a file returns "The file is currently in use."

I have the following method that I use to delete two files, when ran, I receive the message "The file is currently in use."

I believe my mistake is checking to see if the files exists before deleting them, however I've removed that condition and I receive the same message.

 

Any thoughts on how I can improve this function?

 

 

 

public final static void deleteAllDatabase() {
FileConnection fconn_temp = null;
FileConnection fconn = null;
try {
fconn_temp = (FileConnection) Connector
    .open(System.getProperty("fileconn.dir.memorycard")
        + resource.getString(CoffeeHouseResource.db_path)
        + resource
            .getString(CoffeeHouseResource.db_template_name),
        Connector.READ_WRITE);
fconn = (FileConnection) Connector.open(
    System.getProperty("fileconn.dir.memorycard")
        + resource.getString(CoffeeHouseResource.db_path)
        + resource.getString(CoffeeHouseResource.db_name),
    Connector.READ_WRITE);

if (fconn_temp.exists() && fconn.exists()) {
  fconn_temp.delete();
  fconn.delete();
}

} catch (IOException e) {
Logger.logEventError("deleteAllDatabase error: " + e.getMessage());
} finally {
if (fconn_temp != null) {
  try {
    fconn_temp.close();
  } catch (IOException e) {
  }
}
if (fconn != null) {
  try {
    fconn.close();
  } catch (IOException e) {
  }
}
}
}

 

 

--Todd

Windows 7 Enterprise 64-bit (6.1 Build 7600) | Java SE Runtime Environment (build 1.6.0_24-b07) | Eclipse Version: 3.6.2 [M20110210-1200] | BlackBerry Eclipse Plug-in: 1.3.0.201102031007-19 | Java Compiler level: 1.3 | Targeting devices running OS 5 | Simulators: JDE 5.0 packaged 9700, 9630, 9300
Highlighted
Regular Contributor
Posts: 64
Registered: ‎01-27-2011
My Device: Not Specified

Re: Deleting a file returns "The file is currently in use."

I believe its the common path names between both your file connections that are causing the error. Try using one file connection and delete each file individually rather than having two file connections and deleting them concurrently.

Developer
Posts: 298
Registered: ‎05-02-2010
My Device: Bold 9700
My Carrier: Verizon

Re: Deleting a file returns "The file is currently in use."

Thank you, I appreciate your help - kudos to you.

 

I just deleted the directory that contained both files instead of trying to delete each file independently.

--Todd

Windows 7 Enterprise 64-bit (6.1 Build 7600) | Java SE Runtime Environment (build 1.6.0_24-b07) | Eclipse Version: 3.6.2 [M20110210-1200] | BlackBerry Eclipse Plug-in: 1.3.0.201102031007-19 | Java Compiler level: 1.3 | Targeting devices running OS 5 | Simulators: JDE 5.0 packaged 9700, 9630, 9300