Reputation: 644
Need Suggestions po : SQLite or JSON?
I am creating a Simple Quiz Game, I have tried playing with JSON Parsing. and got forgotten of SQLite because of what it can do. JSON can add new questions, update, remove and search on it.
I am writing all my questions data in a JSON File, parsing each questions, and add them all in an ArrayList then handle every question inside that ArrayList of Questions.
but what do you think is the best way to use? SQLite or JSON? Thanks in advance po.
Upvotes: 0
Views: 1972
Reputation: 13529
I had same question developing my Android game Taboost.
In the beginning I stored all the cards in a file in xml (could have been json). When the cards started to be more than 200 the loading of the xml file and parsing started to be slow and I switched to SQLite. Implementing the SQLite was a little more difficult but then loading 500+ words from the SQLite has revealed to be faster than parsing a file with xml/json.
So if you have few questions you can go with both xml OR json OR SQLite but SQlite will take more time to set up. When you start to have a lot of questions it might be more efficient to use SQLite.
If you love JSON and you have thousands of string you could even use the couchdb porting for Android
Upvotes: 3
Reputation: 3292
Well, besides both ways could lead you to solve your problem, if you're developing a local app with no "web service" interaction, going for SQLite gives you an elegant an easy way to go fror a CRUD.
JSON is a way to lightly encode objects with the aim in transfer data over the network. if your responses are in a web/application server outside the Android devices you're targenting, this definitely your best option. For local use, you need to create all your CRUD handling, something that already you have out of the box with Android SQLlite helpers.
One nice third option is to use ORMlite, wich I've think is better for your needs:
http://ormlite.com/sqlite_java_android_orm.shtml
But again, is up to you wich to use. Regards.
Upvotes: 0
Reputation: 21015
If you don't have a massive relational model structure, stick with JSON or just implement serializable or Parcelable. If you do , consider sqlite
Upvotes: 1
Reputation: 13564
First off, you are comparing apples to oranges here. JSON is a data format, where SQLite is a database. If you need to persist data that will change during the use of your application, then SQLite will be the right choice. If you need to store data that doesn't change (or perhaps only when there is an update to the app), storing it in a file (which could be JSON) makes sense.
Upvotes: 0