ozo
ozo

Reputation: 111

Data caching in Retrofit2

I did a project with retrofit2 and it works well. Project has 2 parts and each part gets data(Json object) from server with retrofit2. Now, I want to add cache system. I searched but I didn't find a good example. I have data which are object, string, integer(not image). I guess okhttp3 is best cache for my project. Can you explain best way for caching and can you share a good example. My plan:

Upvotes: 0

Views: 243

Answers (2)

ozo
ozo

Reputation: 111

I used TinyDB for caching in android.

Upvotes: 0

Vincent Etienne
Vincent Etienne

Reputation: 40

To do that you'll need to implement a local database. I recommand you to use Room its quite simple to understand it.

You can find documentation here : https://developer.android.com/training/data-storage/room/index.html

Upvotes: 1

Related Questions