title: displaying preloaded bitmap in webview
body: <p>I have a custom ListView that does a lazy load of remote images. When you click a listitem, it starts a new Activity and displays the image in a webview. 
  The problem is, the webview always loads the images, even if the image was preloaded by the listview adapter. I want the WebView to load the image <strong>only</strong> if it was not preloaded!</p>
  
  <p>Here is how I preload the images in the listview:</p>
  
  <pre><code>public void DisplayImage(String url, ImageView imageView)
  {
      imageViews.put(imageView, url);
      Bitmap bitmap=memoryCache.get(url);
      if(bitmap!=null)
          imageView.setImageBitmap(bitmap);
      else
      {
          queuePhoto(url, imageView);
          imageView.setImageResource(stub_id);
      }
  }
  </code></pre>
  
  <p>The lazy-loaded images are stored in a FileCache:</p>
  
  <pre><code>public FileCache(Context context){
      //Find the dir to save cached images
      if (android.os.Environment.getExternalStorageState().equals(android.os.Environment.MEDIA_MOUNTED))
          cacheDir=new File(android.os.Environment.getExternalStorageDirectory(),"LazyList");
      else
          cacheDir=context.getCacheDir();
      if(!cacheDir.exists())
          cacheDir.mkdirs();
  }
  
  public File getFile(String url){
      //I identify images by hashcode. Not a perfect solution, good for the demo.
      String filename=String.valueOf(url.hashCode());
      //Another possible solution (thanks to grantland)
      //String filename = URLEncoder.encode(url);
      File f = new File(cacheDir, filename);
      return f;
  
  }
  </code></pre>