1

I have a Sqlite db file which have 1000's of records which I want to display with RecyclerView. If I fetch the data and store them in a List it takes 10s to loop through all the data. Then when I assign this List to RecyclerView data adapter, it takes almost 10 extra seconds to cache the data for displaying. So its spending about 20s in this entire process.

Is there any why to directly connect the SQLite db query cursor with RecyclerView, so it can display data one by one instead of retrieving all 1000s of data and cache it?

codelearner
  • 1,354
  • 1
  • 16
  • 32

3 Answers3

4

You should use pagination for these cases.you can use queries like this :

SELECT * FROM YOUR_TABLE LIMIT 10 OFFSET 0 //for page #1
SELECT * FROM YOUR_TABLE LIMIT 10 OFFSET 10 // for page #2

and check this url to implementing pagination : How to implement endless list with RecyclerView?

Community
  • 1
  • 1
Reza.Abedini
  • 2,227
  • 2
  • 16
  • 18
0

Try to show the view with load more, like when user scrolls down then load the data..

Manoj Vayu
  • 99
  • 6
0

I agree with Manoj.... Show some items and as the users keeps scrolling load and add next items to the list and use notifyDataSetChanged().this will help you

Arpan Sharma
  • 2,142
  • 11
  • 22