title: Do not treat position as fixed; only use immediately
body: <p>I have this error in my code:</p>
  <pre><code>Do not treat position as fixed; only use immediately and call holder.getAdapterPosition() to look it up later.
  </code></pre>
  <p>I even used <code>holder.getAdapterPosition()</code> in the position place, but it still keeps crashing the app when I click the items.</p>
  <pre class="lang-java prettyprint-override"><code>MusicAdapter(Context mcontext, ArrayList&lt;MusicFile&gt; mfiles) {
      this.mfiles = mfiles;
      this.mcontext = mcontext;
  }
  
  @Override // androidx.recyclerview.widget.RecyclerView.Adapter
  public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
      return new MyViewHolder(LayoutInflater.from(this.mcontext).inflate(R.layout.music_items, parent, false));
  }
  
  public void onBindViewHolder( final MyViewHolder holder,  int position) {
      holder.file_name.setText(this.mfiles.get(position).getTitle());
      byte[] image = getAlbumArt(this.mfiles.get(position).getPath());
      if (image != null) {
          Glide.with(this.mcontext).asBitmap().load(image).into(holder.album_art);
      } else {
          Glide.with(this.mcontext).load((int) R.drawable.ic_launcher_background).into(holder.album_art);
      }
  
  
  
      holder.itemView.setOnClickListener(new View.OnClickListener() {
  
          public void onClick(View view) {
              Intent intent = new Intent(MusicAdapter.this.mcontext, PlayerActivity.class);
              intent.putExtra(&quot;position&quot;, holder.getAdapterPosition());
              MusicAdapter.this.mcontext.startActivity(intent);
          }
      });
  }
  
  @Override // androidx.recyclerview.widget.RecyclerView.Adapter
  public int getItemCount() {
      return this.mfiles.size();
  }
  
  public class MyViewHolder extends RecyclerView.ViewHolder {
      ImageView album_art;
      TextView file_name;
      LinearLayout linearLayout;
  
      public MyViewHolder(View itemView) {
          super(itemView);
          this.file_name = (TextView) itemView.findViewById(R.id.music_file_name);
          this.album_art = (ImageView) itemView.findViewById(R.id.music_img);
          linearLayout = itemView.findViewById(R.id.linear_layout);
      }
  }
  
  private byte[] getAlbumArt(String uri) {
      MediaMetadataRetriever retriever = new MediaMetadataRetriever();
      retriever.setDataSource(uri);
      byte[] art = retriever.getEmbeddedPicture();
      retriever.release();
      return art;
      }
  }
  </code></pre>