title: Online/Offline Image Management Strategy
body: <p>I am working on an app that will <em>get data and images from the <code>webservice</code> and store it in device for offline usage</em>. At the same time the application will have some data stored in <code>sqlite db</code> and some images as the default data. </p>
  
  <p><strong>Here is the flow of app:</strong></p>
  
  <ul>
  <li>When the application opens it will grab the data from <code>Sqlite Db</code> and
  image paths of images stored in device and display them.</li>
  <li>Beside that if there is internet connection, data and images from
  <code>webservice</code> will be consumed and copied to the <strong><code>Sqlite DB(data)</code></strong>
  and to the <strong><code>device(images)</code></strong> to be later accessed offline</li>
  </ul>
  
  <p><strong>Here is the question:</strong></p>
  
  <blockquote>
    <p>What is the best strategy to do that (note that i want also to prevent
    images shown in gallery of the device. They will be able to be accesed
    only from the app)?</p>
  </blockquote>
  
  <ul>
  <li>Should i store default images firstly in <code>Assets Folder</code> and copy
  them to the <em>external directory</em> on the first oppening. And for <em>offline
  usage of the images from the webservice</em>, download and save them to the
  same directory?</li>
  <li>Should i store local images in drawables and downloaded images in
  external directory of the device?</li>
  <li>Should i store all images in SqliteDb as binary data (which i dont
  prefer because of performance)</li>
  </ul>
  
  <p>Also take in consideration that i want to store multiple images for different device sizes. So on the first opening i check the device from which <code>drawable folder (xxhdpi, xhdpi, hdpi, mdpi)</code> it takes the images like so:</p>
  
  <pre><code> DisplayMetrics metrics = new DisplayMetrics();
  getWindowManager().getDefaultDisplay().getMetrics(metrics);
  switch(metrics.densityDpi){
                  case DisplayMetrics.DENSITY_MEDIUM:
                      break;
                  case DisplayMetrics.DENSITY_HIGH:
                      break;
                  case DisplayMetrics.DENSITY_XHIGH:
                      break;
                  case DisplayMetrics.DENSITY_XXHIGH:
                      break;
              }
  </code></pre>
  
  <p>store to what folder it goes on <code>SharedPreferences</code>so when i download images from the service, it will go <em>to the specific folder with specfic image sizes</em> of <code>webservice</code> and grap them</p>
  
  <blockquote>
    <p>What is the best and easy strategy to manage images in this case?</p>
  </blockquote>
  
  <p>[note: I dont want to use <code>google extension files</code> as the data and images can be udated frequently]</p>