开发者

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 som开发者_Go百科e voodoo magic that will help me?


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.


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜