JSON file VS SQLite android JSON file VS SQLite android sqlite sqlite

JSON file VS SQLite android


Advantages of SQLite:

  • Changes are ACID
  • You can make complex requests faster (e.g. "give me only fields A,B from items with (C/D)>E")
  • I would bet more compact for big data (integers are stored as integers instead of a string of individual digit)
  • Only one file
  • You can merge old data with new data easily
  • You can update current data, even while using it
  • Concurrency can be handled

Advantages for JSON/CSV:

  • Easier to debug (plain text)
  • Faster to make a whole update (copy the new file + delete the old one)

For the original question the whole delete/replace of the data makes JSON/CSV the winner.

However, if the application was to retrieve partial data every 10s and merge/update it with the previous one, SQLite would be a better option.


Sqlite is mostly used when you want data to be saved and used in future. In your case data is changing every 5 minutes so its better to have JSON because every time to make the Database connection store and retrieve after 5 minutes will take some time.

UPDATE:

I also had the same Application in which the data was changing every time. In that case I used Map<K, V> and ArrayList to maintain the values, because as the data is changing everytime I think its not feasible to store the data in Sqlite everytime. It needs much time to perform DB Connection store, retrieve, update the data in Sqlite.


I recommend using JSON or some type of object serialisation unless:

  • You need ACID compliance for write operations
  • You need to report against the data which may involve copying the data to an external RDBMSor
  • You wish to join those complicit in the overuse / abuse of databases, as commonly seen nowadays