My App is not loaded in Blackberry simulator
I am using following code to create xml file -
void createxml(){
Document d = new Document();
Element root = d.createElement("","company");
Element employee = d.createElement("","employee");
employee.setAttribute("","id","1");
Element fname = d.createEle开发者_如何学Pythonment("","fname");
fname.addChild(Node.TEXT,"Vasudev");
Element lname = d.createElement("","lname");
lname.addChild(Node.TEXT,"Kamath");
Element address = d.createElement(Node.TEXT+"","address");
address.addChild(Node.TEXT,"Karkala");
employee.addChild(Node.ELEMENT,fname);
employee.addChild(Node.ELEMENT,lname);
employee.addChild(Node.ELEMENT,address);
root.addChild(Node.ELEMENT,employee);
d.addChild(Node.ELEMENT,root);
String fileName = "file:///SDCard/Blackberry/company.xml";
DataOutputStream os = null;
FileConnection fc = null;
try
{
fc = (FileConnection)Connector.open(fileName,Connector.READ_WRITE);
if (! fc.exists())
fc.create();
os = fc.openDataOutputStream();
KXmlSerializer serializer = new KXmlSerializer();
serializer.setOutput(os, "UTF-8");
d.write(serializer);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
But when I write this method, my program is not going to be load on the simulator, if I comment It loads easily. How do i solve this problem?
Do u simulate your app? If you running in simulator, create a filder SDCard in your system and then create a sub folder Blackberry. And when you run your app take take the 'Simulate' menu > Change Sd card> Add Directory> and browse for the folder SDcard .... then run you app
精彩评论