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

New Developer
Posts: 43
Registered: ‎08-23-2008
My Device: Not Specified

XML issue

I am having a XML file added to the code file and i can be able to read it.
I open the file using
            DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
            DocumentBuilder builder = factory.newDocumentBuilder();
            InputStream inputStream = getClass().getResourceAsStream("test.xml" );
            Document document = builder.parse( inputStream );
This is working fine. But when i open it for writing using Fileconnection it is giving me ":" required in the URL exception.

FileConnection fconn = (FileConnection)Connector.open("test.xml",Connector.READ_WRITE);
dos= fconn.openDataOutputStream();
After this i created xml file under SDCard folder in computer file system and changed filepath in code to file:///SDCard/test.xml it worked fine for writing but problem in reading.
Actually my need is i want XML file to be located on the device/simulator. I need to use the same for read and write also append.
Also need to know how to create brand new XML file in the device using code.
Appriciate u r help.
BlackBerry Development Advisor
Posts: 15,852
Registered: ‎07-09-2008
My Device: BlackBerry PRIV
My Carrier: Bell

Re: XML issue

You can simulate a micro SD card in the BlackBerry Simulator.  This link explains how to do this.


How To - Use a computer file system as a microSD card
Article Number: DB-00654



This allows you create/view/edit files on your PC and within the BlackBerry Simulator.

Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.