Best way to read file with questions and answers

Hello,

I need to load in a file that has a question and four possible answers. I need to mark one of the answers as being the correct one. I could even do that with placing a * at the front of the answer and parse it out when displaying it. There will be 100 - 200 of these in one file. It will be downloaded from my server to the app.

When is the best way to have these in a file to read them? Should I just put them all on one line with a delimited character to split them as?

One other thing I need to do is I need to make some of these questions so I can go back and study just those. How hard is it to mark the lines in the file and save them again? Or is there a better way?

Thanks!

Warren

Actually I was looking at the data I have now and it is formatted like this. So I guess I can read it in line by line. Can I mark the question to be a favorite? Or is my best bet to create another small file that has the question number in it and update it?

Last, what can I load all of the questions/answers in? An array? That’s the same as a table here right?

1. WHAT ANATOMICAL TERM PERTAINS TO THE LOWER END OF THE BODY? A. PROXIMAL B. DISTAL C. INFERIOR D.\* CAUDAL

After reading the docs more can I do this? I am assigning the test from the lines to variables and then placing in the array. Z is the counter for the array and increments for each new one. It may not be very efficient but will it work in your eyes? I just need to see how to loop through the array next. Guess just know how many are in the array by saving what Z is and then loop through?

Z = 1 Q1 = "What is your favorite color?" R1 = "Blue" R2 = "Red" R3 = "Green" R4 = "Brown" a = {} a[Z] = {Q1,R1,R2,R3,R4} --Assign new values to the variables here --Now add this to the next array Z = Z + 1 a[Z] = {Q1,R1,R2,R3,R4} etc...

Personally I would create either a sqlite database or json

I used JSON for the local version of my questions for my trivia game.  The main questions are stored in a mySQL database on my webserver and fetched from there, but for offline play I have a local copy in JSON format.

I can use the SQLite for offline also since it is on the device right?

Yes, it’s local to the device.

Actually I was looking at the data I have now and it is formatted like this. So I guess I can read it in line by line. Can I mark the question to be a favorite? Or is my best bet to create another small file that has the question number in it and update it?

Last, what can I load all of the questions/answers in? An array? That’s the same as a table here right?

1. WHAT ANATOMICAL TERM PERTAINS TO THE LOWER END OF THE BODY? A. PROXIMAL B. DISTAL C. INFERIOR D.\* CAUDAL

After reading the docs more can I do this? I am assigning the test from the lines to variables and then placing in the array. Z is the counter for the array and increments for each new one. It may not be very efficient but will it work in your eyes? I just need to see how to loop through the array next. Guess just know how many are in the array by saving what Z is and then loop through?

Z = 1 Q1 = "What is your favorite color?" R1 = "Blue" R2 = "Red" R3 = "Green" R4 = "Brown" a = {} a[Z] = {Q1,R1,R2,R3,R4} --Assign new values to the variables here --Now add this to the next array Z = Z + 1 a[Z] = {Q1,R1,R2,R3,R4} etc...

Personally I would create either a sqlite database or json

I used JSON for the local version of my questions for my trivia game.  The main questions are stored in a mySQL database on my webserver and fetched from there, but for offline play I have a local copy in JSON format.

I can use the SQLite for offline also since it is on the device right?

Yes, it’s local to the device.