title: Contact Image in listview is repeating when use a Baseadapter
body: <p>I am building an application where I am storing all contact data in my sqlite database and populating that data in listview.</p>
  
  <p>In the process the contact images are repeating and is displayed without any ordering.</p>
  
  <p><strong>The adapter:</strong> </p>
  
  <pre><code>private class ContactAdapter extends SimpleCursorAdapter
  
      {
          //Context context;
          ArrayList&lt;HashMap&lt;String, String&gt;&gt; data;
          private Cursor c;
          private Context context;
          LayoutInflater inflater;
          public ContactAdapter(Context context, int layout, Cursor c, String[] from, int[] to) {
              super(context, layout, c, from, to);
              this.c = c;
              this.context = context;
              inflater = LayoutInflater.from(this.context);
          }
  
  
          @SuppressWarnings("deprecation")
          @SuppressLint("NewApi")
          @Override
          public View getView(int position, View convertView, ViewGroup parent) {
              // TODO Auto-generated method stub
              ViewHolderContact viewHolder;
  
              //viewHolder = new ViewHolderContact();
  
  
              if(convertView==null)
              {
                  viewHolder = new ViewHolderContact();
  
                  convertView = inflater.inflate(R.layout.layout_contactlist, null);
                  viewHolder.imageView = (ImageView) convertView.findViewById(R.id.ivimage);
                  viewHolder.imgNext = (ImageView) convertView.findViewById(R.id.imgnext);
                  viewHolder.textView_Name = (TextView)convertView .findViewById(R.id.txtname);
  
              //  view.imgad.setScaleType(ImageView.ScaleType.FIT_XY);
                  /*view.imgad.setScaleType(ImageView.ScaleType.FIT_XY);
                  //view.imgad.setPadding(0,10,0,0);
                  //view.imgad.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT,100));
                  //LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT,90);
                  LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT,90);
                  lp.setMargins(0,20,0,0);
                  view.imgad.setLayoutParams(lp);
                   */
                  convertView.setTag(viewHolder);
              }
              else
              {
                  viewHolder = (ViewHolderContact)convertView.getTag();
              }
  
              this.c.moveToPosition(position);     
              String contactid = this.c.getString(this.c.getColumnIndex("_id"));
              String contactname = this.c.getString(this.c.getColumnIndex("contactname"));
              String contactnumber = this.c.getString(this.c.getColumnIndex("contactnumber"));
              String contactimage= this.c.getString(this.c.getColumnIndex("contactimage"));
              String isInstalled= this.c.getString(this.c.getColumnIndex("isInstalled"));
  
  
              //System.out.println("Isinstalled---&gt;"+isInstalled);
  
              if(isInstalled.equals("Y"))
              {
                  viewHolder.imgNext.setVisibility(View.GONE);
              }
  
  
              if (contactimage == null || contactimage.equals("")) {
                  if (Build.VERSION.SDK_INT &gt;= 16) {
                      viewHolder.imageView.setBackground(getResources().getDrawable(R.drawable.ic_launcher));
                  }
                  else {
                      viewHolder.imageView.setBackgroundDrawable(getResources().getDrawable(R.drawable.ic_launcher));
                  }
                  // If there is no image in the database "NA" is stored instead of a blob 
                  // test if there more than 3 chars "NA" + a terminating char if more than
                  // there is an image otherwise load the default
              }   //iv.setScaleType(ImageView.ScaleType.CENTER_CROP);
              else{   
                  try {
                      Bitmap bmp=getContactBitmapFromURI(ContactList.this,Uri.parse(contactimage));
                      Bitmap round=getRoundedShape(bmp);
                      viewHolder.imageView.setImageBitmap(round);
  
                  } catch (FileNotFoundException e) {
                      // TODO Auto-generated catch block
                      e.printStackTrace();
                  }
              }
  
              viewHolder.textView_Name.setText(contactname);
  
              return convertView;                 
  
          }
  
          class ViewHolderContact {
              TextView textView_Name;
              ImageView imageView,imgNext;
  
          }
  
      }
  </code></pre>
  
  <p>c is the cursor instance</p>
  
  <p><strong>The method getContactBitmapFromURI(Context context, Uri uri)</strong></p>
  
  <pre><code>public static Bitmap getContactBitmapFromURI(Context context, Uri uri) throws FileNotFoundException {
      InputStream input = context.getContentResolver().openInputStream(uri);
      if (input == null) {
          return null;
      }
      return BitmapFactory.decodeStream(input);
  }
  </code></pre>
  
  <p>Output:</p>
  
  <p><a href="https://i.stack.imgur.com/zVfiF.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/zVfiF.png" alt="Instance 1"></a></p>
  
  <p>When I scroll then the output becomes:</p>
  
  <p><a href="https://i.stack.imgur.com/PItzf.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/PItzf.png" alt="Instance 2"></a></p>
  
  <p>As you can see that the image is not properly displayed.They are repeating or/and disappearing.Please help.</p>