Android Question Best paging approach with a remote DB

Informatix

Expert
Licensed User
Longtime User
I have often the same question from my ULV users:
"How can I read n records from my remote database, then read another n records and so on? How can I display all the records in my view (and not only the last query)?"

I see at least two methods to retrieve the DB contents:
- you execute a query of n records and you save the result in a local database, which is the main DB used by your view; then, when the records are downloaded (or when the user hits the bottom of your listview), you redo another query to get the next n records that you add to your local table, and so on;
- you retrieve all records with a single query and you use directly the recordset (a cursor or a DB result object). EDIT: that does not answer to the question above of course but it's what most people do.

At work, we are used to deal with huge databases and we never apply the second solution because it has important drawbacks (transfer time, no data availabilty while offline) so, from this professional perspective, I usually recommend the first one (a local SQlite DB), but it implies to synchronize the two DBs and that seems a bit complicated for most developers I talk to. So is there a better/easier approach under Android?
 
Last edited:

Informatix

Expert
Licensed User
Longtime User
The idea is the same as the one here but you don't mention how to load the records page by page.
Unless you need extreme speed, using SQlite in memory is IMHO a waste of memory. The performance on disk is already excellent.
 
Upvote 0

Informatix

Expert
Licensed User
Longtime User
I knew Cloudant Sync yet but never tried it. It's not directly useful for B4A users but thanks for the link. It could give an idea to our serial wrappers.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…