Welcome!

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

Reply
New Contributor
farheen
Posts: 6
Registered: ‎02-16-2010
My Device: 9700
My Carrier: Vodafone

save node value in xml file

Hi,

 

I am using setNodeValue() to change the value of node.

 

I am printing nodevalue after using setNodeValue(), then it is showing the updated value. But when i relaunch the application its showing me old value. The xml is not getting updated permanently.

 

 

Here is my code:

 

public XMLParsing()
    {
        ButtonField submit = new ButtonField("Submit");
        add(submit);
        FieldChangeListener listenerSubmit = new FieldChangeListener() {
            public void fieldChanged(Field field, int context) {
                try {
                    
                    builder = factory.newDocumentBuilder();
                    InputStream inputStream = getClass().getResourceAsStream("UrlSaver.xml");
                    Document document = builder.parse( inputStream );
                    Element rootElement = document.getDocumentElement();
                    rootElement.normalize();
                    Dialog.alert(rootElement.getChildNodes().item(1).getChildNodes().item(0).getNodeValue());
                    rootElement.getChildNodes().item(1).getChildNodes().item(0).setNodeValue("www.yahoo.com");
                    Dialog.alert(rootElement.getChildNodes().item(1).getChildNodes().item(0).getNodeValue());

                        } catch (Exception e) {
                    
                    Dialog.alert(e.toString());
                    Dialog.alert("error");
                    e.printStackTrace();
                }
                   
                
                   
            }
            };
            
       submit.setChangeListener(listenerSubmit);

 

Please suggest me how can i change the XML node value permanently.

 

Please use plain text.