title: How to implement caching in android app for REST API results?
body: <p>My android app gets its data using REST API. I want to have client side caching implemented. Do we have any inbuilt classes for this?</p>
  
  <p>if  not, is these any code that i can reuse? I remember coming across such code sometime back. However I cant find it. </p>
  
  <p>If nothing else works, i will write my own. following is basic structure</p>
  
  <pre><code>public class MyCacheManager {
  
  static Map&lt;String, Object&gt; mycache;
  
  public static Object getData(String cacheid) {
      return mycache.get(cacheid);
  }
  
  public static void putData(String cacheid, Object obj, int time) {
      mycache.put(cacheid, obj);
  }
  
  }
  </code></pre>
  
  <p>how do i enable time for cached objects? also - whats the best way to serialize? cache should be intact even if app is closed and reopened later (if time has not expired).</p>
  
  <p>Thanks
  Ajay</p>