I want to store the API response in sqlLite. API reponse is in JSON Format and contain huge data. Due to this application stop working. How can i solve this issue.
Asked
Active
Viewed 112 times
-2
-
Define 'huge'. If you deserialize JSON in memory, then the issue happens long before you hit sqlite... – zaitsman Sep 16 '19 at 04:40
-
Its more than 13 MB data – Dheeraj Sharma Sep 16 '19 at 04:41
-
1That's tiny. Please include some code then. – zaitsman Sep 16 '19 at 04:42
-
I am doing like this... foreach (var Item in jArr) { tbl.Name = Item["Name"].ToString() ; database.Insert(tbl);} – Dheeraj Sharma Sep 16 '19 at 04:42
-
1`application stop working` how exactly? Does it throw exceptions? Which exactly? – Vladyslav Matviienko Sep 16 '19 at 05:00
-
I think you are looking for https://stackoverflow.com/questions/32088056/how-to-bulk-insert-in-sqlite-in-android – Jaiprakash Soni Sep 16 '19 at 05:00
-
when json is inseting into sqllite then a pop up message came with close app and wait – Dheeraj Sharma Sep 16 '19 at 05:07
-
@DheerajSharma Do it on a background thread so you do not block the main/UI thread and cause an ANR. – SushiHangover Sep 16 '19 at 05:10
-
13MB data is highly not reccomended. you must have to refine your service. – Zaid Mirza Sep 16 '19 at 05:11
-
`pop up message came with close app and wait` that is probably because you are working with the DB on the UI thread. – Vladyslav Matviienko Sep 16 '19 at 05:31
-
store it in a file and get read that file when you need the data – Zulqurnain Jutt Sep 16 '19 at 06:15
1 Answers
0
Most of the time it is bad practice to have all JSON in the local store in mobile it makes your API call heavy and mobile speed and performance slow it also affects your third party libraries as well so solution is to make two individual DB SQLite and in which mapped on transitional data in one DB and rest in other so every time you will get live and fast data via transitional table or SQLitestore.