androiddatabaseandroid-networkingapplication-cache

Offline app loading which is a better approach caching or storing in dB


After getting the response from the server if the same network call was called again instead of showing the progress bar we can persist the previous result until the response comes. So I wanted to know which is a better approach is it to store in database or cache the response using http result cache. Say the data can be acted upon until the newer response comes back and which is widely used, any suggestions can be appreciated


Solution

  • Depends on what your use case is. Typically I try to keep it stupidly simple (KISS). Don't use a database unless you have a reason to such as needing to query data or do complex aggregates. Caching the http result or just dumping objects to disk is sufficient for most typical use cases.