8

Give the following scenario. I have a mobile App on iOS/Android which is connected to a server backend via REST. Within the app you can display news items. These items can be created, edited and deleted of you are the creator of the item. On one page in the app there is a news feed where you can see an overview of news items created by other app users. The iOS/Android app stores the data of these news items in a local sqlite database. When the user scrolls down the list of items further items should be loaded if there are any.

The task I want to solve is how the items will be cached in the SQLite database to work with pagination. The cache must be updated sometimes when items are deleted or reordered on the server. This must be taken into account when working with pagination.

Here is the algorithm I've used so far:

  1. if the feed page opens check if there are any items to display in the sqlite database

    • if true retrieve p items with offset offset=0 from the database and contact the server to check if the first p items should be updated or deleted
      • if items should be updated or deleted perform these operations on the items in display
    • else contact the server for p items with offset offset=0 and display them
  2. if the user scrolls down start 1. again with offset = offset + p

How does caching data for mobile apps work with pagination?

3
  • you caould use database and query db as select x row from db when user would scroll.. Commented Jan 18, 2015 at 14:52
  • 1
    @confile did you manage to find an answer to your problem ? Commented Sep 13, 2015 at 9:47
  • @confile I'm also pondering pagination alongside caching in a mobile app. However, I'm finding that there is not a solitary solution and it depends on your application domain. I have not found an article that specifically addresses this question about my application and I don't think I will. However, I did find an article that answers this question for a specific domain. medium.freecodecamp.org/…. It's not an entire solution for me (and probably not you), but the example helped me re-approach the problem. Commented Sep 28, 2018 at 15:52

1 Answer 1

1

The question is how long you want to store data. You can store every data you get in part:

"else contact the server for p items with offset offset=0 and display them"

And set some time stamp to data. When time stamp expires you delete data ( in background ). In this way you save a lot of requests and also you don't waste with memory.

Hope this helps you with your problem.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.