Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What I should pick - JSON or SQLite? [closed]

In my application, on every launch at first some JSON have to downloaded from server and later I need to show various information by parsing this data one the full app life-cycle. The JSON object is pretty big with almost 5000 JSONArray. Every JSON array is of the following form:

[37,101,"The Blocks Problem",9952,0,1000000000,0,852,0,0,11197,0,16606,0,7279,200,18415,5325,14492,3000,1]

So I have two option:

  1. Save the json string into a file and later read it.
  2. Save the JSON array in SQlite database with almost 10 columns and 5000 rows.

The first option seems to be efficient. But later I have to manipulate the JSON for displaying various information. In some cases, I need to search full array to pick on array information and there are many cases like this. So this would be very time consuming also.

The second option is better for searching and displaying faster. So I approached on with the second option. But the insertion of 5000 rows at a time is time consuming also. I did it in AsyncTask for betterment but it is taking too much time to be executed - parsing JSON and store in SQlite table.

So what can I do? what is the best way to store this huge information and later use it efficiently?

like image 911
Kaidul Avatar asked Aug 03 '13 02:08

Kaidul


1 Answers

I answered a question pretty close to this today - File or Database? - Best Practice to save Objects on Android-Device. I wanted to add that if inserting 5000 rows is taking too long, try adding them all in a single transaction, or using a bulk load mechanism. It's worth the effort to figure out your insert problem instead of trying to use files.

See this tutorial about bulk loading SQLite

like image 56
Samuel Avatar answered Sep 28 '22 04:09

Samuel