Question

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?

Was it helpful?

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.

OTHER TIPS

IOExeption go if the firewall disallows a connection that is not btspp or comm. so you have to add permission for your program such as FILE_API ..... you can read book : Advance BB dev to do this

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top