Android Question Classes, Arrays, Lists, Maps ???

demonio_jack

Member
Licensed User
Hi again:
I am sure this is a classic of this forum, but after searching and finding too many solutions that I cannot implement in my code as an efficient solution, I ask you for help to see if anyone has a simple example to help me with this:
I have an SQLite database that I am reading from my device, in it I have TESTS, QUESTIONS AND ANSWERS. As in college or university, the user must take an exam that has a certain number of questions and each of them has 5 possible answers (only one is correct).
How can I load in memory the TEST, its QUESTIONS and the ANSWERS in some type of variable to go through them and display them on the screen?

Thank you very much as always. ?

Demonio
 

demonio_jack

Member
Licensed User
Why to keep them in memory - why not getting them from your DB?
But you can load them into lists and use them like recordsets
It's a good question and that's what I've been doing. I am looking for a more efficient way and not have to be accessing the database (file) every so often.
Thank you very much Alex for the answer (maybe it could be the best solution for now). :cool:
 
Upvote 0

Alex_197

Well-Known Member
Licensed User
Longtime User
It's a good question and that's what I've been doing. I am looking for a more efficient way and not have to be accessing the database (file) every so often.
Thank you very much Alex for the answer (maybe it could be the best solution for now). :cool:
Keep in mind that while it seems faster than taking it from the database you consume more memory which is no good if you have a lot of records.
 
Upvote 0

Brian Dean

Well-Known Member
Licensed User
Longtime User
How can I load in memory the TEST, its QUESTIONS and the ANSWERS in some type of variable

I am not quite sure what you are asking here, but I assume that you are putting your test questions into an object; for instance ...

B4X:
    Type test = (question As String, answers As Array(5) As String, correct As Int)

Then you can move test questions around as single objects, or use a List to build a subset of test questions. But still best to keep the main stock of test questions in a database.
 
Upvote 0
Top