Search code examples
blackberryjava-meblackberry-stormconnector

FileConnection on Storm 9550


I'm using the following code to create a file and write data into it:

fileName = "file:///store/home/user/myapp/groups.xml";    

try {
  fc = (FileConnection) Connector.open(fileName, Connector.READ_WRITE);
  if (!fc.exists())
    fc.create();                
    os = fc.openDataOutputStream();
    String XMLString = "blablabla";
    byte[] FinalXML = XMLString.getBytes();
    os.write(FinalXML);
    os.close();
    fc.close();        
} catch (IOException e) {
  Dialog.alert(e.getMessage());
}

It works good on my bb 9700 with OS6 and on 9700 simulator. But it doesn't work on 9550 device and simulator. I'm getting IOException. The message says

File not found

Does anybody have some voodoo magic that will help me?


Solution

  • Looks like the folder "file:///store/home/user/myapp/" does not exist yet. Just check for its presence first, if not present - create and then go on with rest of your code.

    BTW, the "file:///store/home/user/" path is valid for all mentioned devices.