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?
"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: