0

I have a JSON query for 3000 items. At first launch my app, I have to retrieve this data and put it in SQLite, in next launches the app will get data from db or will ask api about update data. When app is putting data to db, it should show about twenty items in recyclerview with endless list and load more items, when the items are gonna finished. How implement this? I understand that I need to perform these operations in background threads, but how organize it. At first app will retrieve data from asynchronous retrofit 2 request and how then load this data in SQLite and show it in the same time without lags? Should I use contentprovider with cursorloader or something with ORM? Thanks for answers.

MedveDomg
  • 413
  • 1
  • 4
  • 8

1 Answers1

0

First of All You Should not load this much data at once. you should load that data chunk by chunk (Called Pagination), that mean your calling API also be capable for response to you chunk by chunk.

For your problem you might do is

  • Load your data from server
  • Use separate thread or service to handle the data storing into the SQLite.
  • Use Main Thread to represent the data.

Read this two blogs below, hope this will help you to understand how you can resolve your problem.

RecyclerView Pagination, Sqlite from Service

noman404
  • 928
  • 1
  • 8
  • 23