title: How to stop Recyclerview from producing duplicates and stop shuffling items?
body: <p>I am a newbie here and iam developing a notes app. I noticed that my notes in recyclerview are getting duplicated and shuffling positions upon scrolling. I have spend hurs changing and modifying the code but with no luck . Hope you guys go through the code .Thankyou for your time. </p>
  
  <p>**The relevant adapter code is **</p>
  
  <pre><code>                public void setdata(List&lt;NotesEntry&gt; notesEntries) {
                      notesEntryList=notesEntries;  //i used your code here .it gives a null pointer exception
                      notifyDataSetChanged();
                  }
  
                  public List&lt;NotesEntry&gt; getnotesentries() {
                      return notesEntryList;
                  }
  
                  @Override
                  public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
                      try {
  
                          int i = v1.getAdapterPosition();
                          NotesEntry notesEntries = notesEntryList.get(position);
                          id = notesEntries.getId();
                          text = notesEntries.getText();
                          Log.d("idies", text);
                          b1.setText(String.valueOf(id));
                          textview1.setText(text);
                      } catch (Exception e) {
                          e.printStackTrace();
                      }
                  }
  
  
  
                  public interface Itemlistener {
                      void clicked(int clickedposition, View v, int id, String text);
  
                  }
  
                  class Viewholder1 extends RecyclerView.ViewHolder implements View.OnClickListener {
                      public Viewholder1(@NonNull View itemView) {
                          super(itemView);
                          textview1 = (TextView) itemView.findViewById(R.id.textView2);
                          b1 = (Button) itemView.findViewById(R.id.button2);
  
                          b1.setOnClickListener(this);
                          textview1.setOnClickListener(this);
  
                          Log.d("ViewHolder1", "h");
                      }
  
                      @Override
                      public void onClick(View view) {
  
                          itemlistener.clicked(getAdapterPosition(), view, notesEntryList.get(getAdapterPosition()).getId(), notesEntryList.get(getAdapterPosition()).getText());
  
                      }
                  }
  
              }
  </code></pre>
  
  <p><strong>This is how i have implemented my onclick method in main activity</strong>                 </p>
  
  <pre><code>@Override
  public void clicked(int clickedposition, View v, int iditem, String textitem) {
      try {
          switch (v.getId()) {
              case R.id.button2:
                  entries = adapter.getnotesentries();// entries of notes in my list
                  int n = db.Dao().delete(entries.get(clickedposition));
                  retrievetasks();
  
                  break;
              case R.id.textView2:
                  Intent intent = new Intent(MainActivity.this, Notes.class);
                  intent.putExtra("newnotes", defaultnotes);
                  intent.putExtra("id", iditem);
                  intent.putExtra("text", textitem);
                  startActivity(intent);
                  break;
          }
  
      } catch (Exception E) {
          E.printStackTrace();
      }
  
  }
  </code></pre>
  
  <p>}` </p>
  
  <p>I will provide extra code if needed.</p>