7

Problem Description

I'm creating android chat application based on XMPP protocol. Smack is used as a XMPP Client library. In application messages are stored in SQLite database.

Question

How to implement message caching (ex. like it's done in Facebook messenger) ? In case if there are new messages on server download 20 and show to the user, if no show from local database. If user scroll up again check database and server and show next 20 messages.

Is there a open source example available?

Community
  • 1
  • 1
  • Usually when caching data that can be updated on the server causes the client to maintain an offset (counter/timestamp or something similar). These posts explain data sync patterns which you can use to come up with a protocol for your use case: https://stackoverflow.com/questions/10829371/sync-data-between-android-app-and-webserver https://stackoverflow.com/questions/11299208/how-to-synchronize-android-database-with-an-online-sql-server – NewestStackOverflowUser Sep 28 '17 at 10:47
  • I have done same project but used signalR as a communication. At first login I download latest message data (last 3day messages in my case) and store local sqlite db then reflect in view. If you scroll down i download more chunk data using rest api. For realtime messaging store message locally first then display in view. – Dee Nix Oct 04 '17 at 12:54

0 Answers0