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?