title: Android: keep track of number of objects in cache
body: <p>I am building a gallery using a ViewPager. Every time a photo is downloaded I immediately cache it in <code>mMemoryCache</code> which is</p>
  
  <pre><code>mMemoryCache = new LruCache&lt;Integer, Bitmap&gt;(cacheSize) {
          @Override
          protected int sizeOf(Integer key, Bitmap bitmap) {
              // The cache size will be measured in bytes rather than number
              // of items.
              return (bitmap.getRowBytes() * bitmap.getHeight());
          }
      };
  </code></pre>
  
  <p>As you can see <code>sizeOf()</code> returns the number if bytes used, which makes sense. My problem is that my ViewPager's adapter needs to know how many pages I have, which would be the number of objects in my cache. </p>
  
  <p>Any ideas on how I can do it? thanks!</p>