1

Im doing a list view with a XMLDatamodel and i trying to save data in my xml file because i want to keep safe this information after the aplication closes.

I just want to save the text on textarea in "body" of my xml file when the button below is clicked. or is better use a JSON file or a Arraydatamodel?

this is my QML file:

import bb.cascades 1.2

Page {
    Container {
        ListView {
            dataModel: XmlDataModel {
                source: "Data.xml"
            }
            listItemComponents: [
                ListItemComponent {
                        Header {
                            title: ListItemData.title
                        }                       
                },
                ListItemComponent {
                    type: "body"
                    Label {
                        text: ListItemData.title
                    }
                }              
            ]
        }

        TextArea {
            id: nameField
            hintText: "Text To Save in body of XML file"
            preferredHeight: 140
            horizontalAlignment: HorizontalAlignment.Fill
        }

        Container {
            horizontalAlignment: HorizontalAlignment.Center
            Button {
                text: "ADD"
                onClicked: {

                    //SAVE THE TEXT IN TEXTAREA TO A DATA.XML 
                }
            }//end of button
        } // end of Container
    }//end of container
}//end of page

And this is my XML File "Data.xml"

<root>
    <header title="NOTE 1"/>
        <listItem title="THIS IS A BODY OF NOTE 1"/>

    <header title="NOTE 2"/>
        <listItem title="THIS IS A BODY OF NOTE 2"/>

</root>

Please Help Me. Thank You So Much :D .

Michael Donohue
  • 11,776
  • 5
  • 31
  • 44

2 Answers2

0

Have you looked round the BB10 Microsite that you will find here:

http://developer.blackberry.com/native/

In this case, the issue appears to be making data persistent, in which case I would encourage you to review the samples that you find here:

http://developer.blackberry.com/native/sampleapps/

I think the "Data Management" samples might provide you with examples of what you need, I would look specifically at the Persistent Objects sample and the JSON sample - I appreciate you don't have JSON data, but the concepts should be similar.

And do look round the microsite in general, there is a lot of interesting stuff there.

Peter Strange
  • 2,640
  • 11
  • 11
0

The contents of the XmlDataModel are quite rigid. If you want to save things to your model, consider using the GroupDataModel

Igbanam
  • 5,904
  • 5
  • 44
  • 68