Reputation: 328
I'm reading a web service that returns a JSON, parse and write into a SQLite Database in Android. The process is very slow because I have to do each insertion separately.
I do this process in background
Is there a way to improve this process?
Thank you!!!
Upvotes: 0
Views: 549
Reputation: 1182
You should do batch inserts.
Pseudocode:
db.beginTransaction();
for (entry : listOfEntries) {
db.insert(entry);
}
db.setTransactionSuccessful();
db.endTransaction();
That increased the speed of inserts extremely.
If it doesn't work check out this post about faster insertions
Upvotes: 1