Pablo Reyes
Pablo Reyes

Reputation: 303

Best way to get information: xml? sqlite?

I'm developing an application where I have to fill some views with different data. A similar case would be the "Who wants to be a millionare" game. I need to have a random question with its possible answers. What would be the best way to do it?

I thought on having a /res/xml/questions file with a structure like this:

    <questions>
       <question text="Question1" id="q1">
            <answer id="a1" text="A1" correct="0"/>
            <answer id="a2" text="A2" correct="0"/>
            <answer id="a3" text="A3" correct="1"/>
            <answer id="a4" text="A4" correct="0"/>
       </question>
       ...
    </questions>

But what would be the best way to use the language support that android offers? Should the text of every question be something like "@string/q1"?. That way, I could have the questions/answers in different languages.

Another thing is: How should I fill the TextView for the question and the text of the buttons? Should I read the xml with SAX?

Do you think that sqlite could be a better option?

Upvotes: 0

Views: 406

Answers (2)

Necronet
Necronet

Reputation: 6813

What i would do is to have a XML Service to being call to update a local XML... in that way you will be serving datas update and i think is easier and faster to access and parse XML than use SQLite.... so basicly you can use the XML for Q&A for being answer and if you need to change those answer you can get a new one from a webservice

Upvotes: 0

Ted Hopp
Ted Hopp

Reputation: 234795

I would recommend using sqlite for storing the data. That way you could download more data dynamically. I'd package the initial data as resources in XML and use that to populate the data base.

Start by developing a good data model. You can then translate it into both an XML schema and an SQL schema. It can also help with designing the in-process data structures. It will also help guide you when/if you want to modify it (e.g., partial-credit answers, etc.)

Upvotes: 2

Related Questions