title: How do I update recyclerView inside onBindViewHolder of its adapter?
body: <p>I've made a list of cards inside recyclerView. When card is held for sometime, its corresponding entry in database is deleted so after that, the card must be removed. It can be done by calling setting new updated adapter. But I'm unable to use setAdapter function inside onBindViewHolder because I don't know how to get same recyclerView. Please help.</p>
  
  <p>CODE:</p>
  
  <pre><code>public class RecyclerViewAdapterMain extends RecyclerView.Adapter&lt;RecyclerViewAdapterMain.ViewHolder&gt; {
  
  String[] strings;
  DBManager dbManager;
  
  public RecyclerViewAdapterMain(String[] arrayList) {
      this.strings = arrayList;
  }
  
  @Override
  public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
      View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.card_list,parent,false);
      ViewHolder viewHolder = new ViewHolder(view);
      return viewHolder;
  }
  
  @Override
  public void onBindViewHolder(final ViewHolder holder, final int position) {
      holder.textView.setText(strings[position]);
      holder.cardView.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View view) {
              Intent intent = new Intent(holder.itemView.getContext(),SecondActivity.class);
              Bundle bundle = new Bundle();
              bundle.putString("list",strings[position]);
              intent.putExtras(bundle);
              holder.itemView.getContext().startActivity(intent);
              //overridePendingTransition(R.anim.abc_fade_in,R.anim.abc_fade_out);
          }
      });
      holder.cardView.setOnLongClickListener(new View.OnLongClickListener() {
          @Override
          public boolean onLongClick(final View view) {
              DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() {
                  @Override
                  public void onClick(DialogInterface dialog, int which) {
                      switch (which){
                          case DialogInterface.BUTTON_POSITIVE:
                              dbManager = new DBManager(holder.itemView.getContext(),null,null,1);
                              dbManager.deleteList(strings[position]);
                              String[] strings = dbManager.showLists();
                              RecyclerViewAdapterMain recyclerViewAdapter = new RecyclerViewAdapterMain(strings);
                              //I WANT TO SET UPDATED ADAPTER HERE
                              break;
  
                          case DialogInterface.BUTTON_NEGATIVE:
                              //No button clicked
                              break;
                      }
                  }
              };
              AlertDialog.Builder builder = new AlertDialog.Builder(holder.itemView.getContext());
              builder.setMessage("Are you sure that you want to delete \""+strings[position]+"\"?").setPositiveButton("Yes", dialogClickListener)
                      .setNegativeButton("No", dialogClickListener).show();
              return true;
          }
      });
  
  
  }
  
  @Override
  public int getItemCount() {
      return strings.length;
  }
  
  public class ViewHolder extends RecyclerView.ViewHolder{
      CardView cardView;
      TextView textView;
      public ViewHolder(View itemView) {
          super(itemView);
          textView = (TextView) itemView.findViewById(R.id.textView);
          cardView = (CardView) itemView.findViewById(R.id.cardView);
      }
  }
  </code></pre>
  
  <p>}</p>