简体   繁体   中英

How to create recycler view like WhatsApp chat

I have created a list view just like a whatsapp chats list which is working fine it is loading data from server and setting its view but the problem is when the device is offline it cannot show the view which was previsouly created so my question is how to save the list view offline so that when the device is online my app recieves views from server and if the device is offline then the app should show views which were previously loaded.

And if possible please share some tutorials related to this.

You need to save your data locally using database. The most common option is sqlite. You can try this tutorial to understand what to do: http://www.tutorialspoint.com/android/android_sqlite_database.htm there are some options like Sugar Orm (or any other ORM) which uses sqlite in the background but makes it easy to work with objects (the shortage is that you are very limited when it comes to relations between tables and such). Anyway, this is their website: http://satyan.github.io/sugar/

You can try using Firebase database for your chats. You Just need one line of code to enable chats offline persistence ie FirebaseDatabase.getInstance().setPersistenceEnabled(true); For more take a look on offline-capabilities .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM