Reputation: 818
Im working on a self-test app. And I wondering on how to store the data, I've got over 200 questions and more is on the way. Was thinking of storing them as XML but didnt find a way to get a random question without reading the whole string-array to a variable, which is bad for the memory. So the correct way to go is to use a SQL-database, right?
But how do I make such a database so that it exists at boot and dont need to be made during start up? Can't seem to find any tutorial on this subject, on how to handle questionnaires.
Upvotes: 2
Views: 213
Reputation: 75982
Here's a good tutorial on SQLite and Content Provider. It'll introduce you to using SQL databases on Android, and wrapping them into a ContentProvider
.
As for how to get the data to the device - you have two options:
.db
file in the application assets
folder. Pros: the database is ready for consumption on the first run of the app. Cons: your .apk is too big. Updating is hard..db
file with the first 10 questions. Pros: Your users can start using the app immediately, while you download the rest of the questions in the background. Cons: You have to pick 10 questions you're likely to never or rarely change, or you risk your app to start with outdated data. Upvotes: 2
Reputation: 93561
Create the db offline and either put it in the apk or download it.
Upvotes: 0