title: android universal image loader clear cache
body: <p>i use universal image loader to load image from url<br>
  this is adapter</p>
  
  <pre><code>public class BinderDataImg extends BaseAdapter {
  
  static final String KEY_IMG = "img";
  LayoutInflater inflater;
  List&lt;HashMap&lt;String,String&gt;&gt; imgHashmap;
  ViewHolder holder;
  
  ImageLoader imageLoader = ImageLoader.getInstance();
  
  public BinderDataImg(Activity act, List&lt;HashMap&lt;String,String&gt;&gt; map) {
      this.imgHashmap = map;
      inflater = (LayoutInflater) act
              .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
  }
  
  public int getCount() {
      // TODO Auto-generated method stub
      return imgHashmap.size();
  }
  
  public Object getItem(int arg0) {
      // TODO Auto-generated method stub
      return null;
  }
  
  public long getItemId(int position) {
      // TODO Auto-generated method stub
      return 0;
  }
  
  public View getView(int position, View convertView, ViewGroup parent) {
      View vi=convertView;
      if(convertView==null){
          vi = inflater.inflate(R.layout.list_img, null);
          holder = new ViewHolder();
          holder.iv_img =(ImageView)vi.findViewById(R.id.imageViewImg);
  
          vi.setTag(holder);
      }
      else{
  
          holder = (ViewHolder)vi.getTag();
      }
  
      String uri = imgHashmap .get(position).get(KEY_IMG);
  
      imageLoader.displayImage(uri, holder.iv_img);
  
      return vi;
  }
  
  static class ViewHolder{
      ImageView iv_img;
  }
  </code></pre>
  
  <p>}</p>
  
  <p>this is activity</p>
  
  <pre><code>List&lt;ClassImg&gt; imgList = null;
  DisplayImageOptions defaultOptions = new DisplayImageOptions.Builder()
              .cacheOnDisk(true).cacheInMemory(true)
              .imageScaleType(ImageScaleType.EXACTLY)
              .bitmapConfig(Bitmap.Config.RGB_565)
              .resetViewBeforeLoading(true)
              .displayer(new FadeInBitmapDisplayer(300))
              .showImageForEmptyUri(R.drawable.hinh_error)
              .showImageOnFail(R.drawable.hinh_internet)
              .showImageOnLoading(R.drawable.hinh_loading)
              .build();
  
      ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(getApplicationContext())
              .defaultDisplayImageOptions(defaultOptions)
              .memoryCache(new WeakMemoryCache())
              .threadPoolSize(3)
              .diskCacheSize(100 * 1024 * 1024)
              .build();
  
      ImageLoader.getInstance().init(config);
  
      final CustomListView lvi = (CustomListView)findViewById(R.id.listViewHinh);
  
      try {
          XmlPullParser parser = new XmlPullParser();
          imgList = parser.parse(getAssets().open(file_xml);
          BinderDataImg binderdata = new BinderDataImg(this, imgHashmap);
          lvi.setAdapter(binderdata);
  
      }catch(IOException e) {
          e.printStackTrace();
      }
  }
  </code></pre>
  
  <p>I can load image and image cache in memory and disk is perfect.<br>
  but I want when activity start cache will clear or when press back button to leave activity will delete cache in memory and cache in disk.<br>
  how to do that?<br>
  sorry for my bad English<br>
  thank for reading.</p>