title: Download Manager to be adapted to recyclerview
body: <p>I went through almost all what is available on internet about downloading a file from internet and one of the tutorials worked<br> In that tutorial they've used download manager but it was for a button ..i'm using a recyclerview with items having a single dwonload button and each download button of the items list has a different url , please show me how to do that!<br>
  what i've tried:( i know it's not the right syntax for <code>personViewHolder.personbutton.setOnClickListener</code> but just to show you what i kinda want)</p>
  
  <p>Photo from the emulator of my app!<br></p>
  
  <p><img src="https://i.imgur.com/Qe78Mbk.png&lt;br" alt="pic"></p>
  
  <p>RVadapter.java</p>
  
  <pre><code>public class RVAdapter extends RecyclerView.Adapter&lt;RVAdapter.PersonViewHolder&gt; {
  
  
      public static class PersonViewHolder extends RecyclerView.ViewHolder {
          CardView cv;
          TextView personName;
          TextView personAge;
          ImageView personPhoto;
          Button personbutton;
  
          PersonViewHolder(View itemView) {
              super(itemView);
              cv = (CardView)itemView.findViewById(R.id.cv);
              personName = (TextView)itemView.findViewById(R.id.person_name);
              personAge = (TextView)itemView.findViewById(R.id.person_age);
              personPhoto = (ImageView)itemView.findViewById(R.id.person_photo);
              personbutton=(Button)itemView.findViewById(R.id.imgbuttondownload);
  
          }
      }
  
      List&lt;Person&gt; persons;
  
      RVAdapter(List&lt;Person&gt; persons){
          this.persons = persons;
      }
  
      @Override
      public void onAttachedToRecyclerView(RecyclerView recyclerView) {
          super.onAttachedToRecyclerView(recyclerView);
      }
  
      @Override
      public PersonViewHolder onCreateViewHolder(ViewGroup viewGroup, int i) {
          View v = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.item, viewGroup, false);
          PersonViewHolder pvh = new PersonViewHolder(v);
          return pvh;
      }
  
      @Override
      public void onBindViewHolder(PersonViewHolder personViewHolder, final int i) {
          personViewHolder.personName.setText(persons.get(i).name);
          personViewHolder.personAge.setText(persons.get(i).age);
          personViewHolder.personPhoto.setImageResource(persons.get(i).photoId);
          personViewHolder.personPhoto.setOnClickListener(new View.OnClickListener(){
              public void onClick(View v) {
                  Context context=v.getContext();
                  Intent intent=new Intent();
                  switch (i){
                      case 0:
                          intent =  new Intent(context, MainActivity.class);
                          context.startActivity(intent);
                          break;
                      case 1:
                          intent =  new Intent(context, MainActivity.class);
                          context.startActivity(intent);
                          break;
                      case 2:
                          intent =  new Intent(context, MainActivity.class);
                          context.startActivity(intent);
                          break;
                      case 3:
                          intent =  new Intent(context, MainActivity.class);
                          context.startActivity(intent);
                          break;
                  }
              }
          });
  
          personViewHolder.personbutton.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                  switch (i){
                      case 0:
                  String url = "http://www.androidtutorialpoint.com/wp-content/uploads/2016/09/Beauty.jpg";
                          DownloadManager manager = (DownloadManager) getSystemService(Context.DOWNLOAD_SERVICE);
                          DownloadManager.Request request = new DownloadManager.Request(Uri.parse(url));
                  request.setDescription("my title");
                  request.setTitle("my description");
  
                  request.allowScanningByMediaScanner();
                  request.setNotificationVisibility(
                          DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
  
                  request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, "file"+i+".mp4");
                          manager.enqueue(request);
                  break;
                      case 1:
                          String url2 = "http://www.androidtutorialpoint.com/wp-content/uploads/2016/09/Beauty.jpg";
                          DownloadManager manager2 = (DownloadManager) getSystemService(Context.DOWNLOAD_SERVICE);
                          DownloadManager.Request request2 = new DownloadManager.Request(Uri.parse(url2));
                          request2.setDescription("my title");
                          request2.setTitle("my description");
  
                          request2.allowScanningByMediaScanner();
                          request2.setNotificationVisibility(
                                  DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
  
                          request2.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, "file"+i+".mp4");
                          manager2.enqueue(request2);
                          break;
  
  
              }
          }
      });
      }
  
      @Override
      public int getItemCount() {
          return persons.size();
      }
  }
  </code></pre>
  
  <p>Mainactivity.java</p>
  
  <pre><code>public class Main4Activity extends Activity {
  
      private List&lt;Person&gt; persons;
      private RecyclerView rv;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
  
          setContentView(R.layout.activity_main4);
  
          rv=(RecyclerView)findViewById(R.id.rv);
  
          LinearLayoutManager llm = new LinearLayoutManager(this);
          rv.setLayoutManager(llm);
          rv.setHasFixedSize(true);
  
  
          initializeData();
          initializeAdapter();
  
      }
  
  
  
      private void initializeData(){
          persons = new ArrayList&lt;&gt;();
          persons.add(new Person("How to perform a staphylectomy | Surgical correction of RLN", "10:07", R.drawable.chirurgie,"http://www.androidtutorialpoint.com/wp-content/uploads/2016/09/Beauty.jpg"));
          persons.add(new Person("How to perfom a clinical examination", "07:03", R.drawable.chirurgie,"http://www.androidtutorialpoint.com/wp-content/uploads/2016/09/Beauty.jpg"));
          persons.add(new Person("How to perform a radiographic examination", "03:50", R.drawable.chirurgie,"http://www.androidtutorialpoint.com/wp-content/uploads/2016/09/Beauty.jpg"));
          persons.add(new Person("How to perform a endoscopic examination", "03:50", R.drawable.chirurgie,"http://www.androidtutorialpoint.com/wp-content/uploads/2016/09/Beauty.jpg"));
          persons.add(new Person("How to perform a staphylectomy | Surgical correction of RLN", "03:50", R.drawable.chirurgie,"http://www.androidtutorialpoint.com/wp-content/uploads/2016/09/Beauty.jpg"));
          persons.add(new Person("How to perform a radiographic examination", "03:50", R.drawable.chirurgie,"http://www.androidtutorialpoint.com/wp-content/uploads/2016/09/Beauty.jpg"));
          persons.add(new Person("How to perform a radiographic examination", "03:50", R.drawable.chirurgie,"http://www.androidtutorialpoint.com/wp-content/uploads/2016/09/Beauty.jpg"));
          persons.add(new Person("How to perform a radiographic examination", "03:50", R.drawable.chirurgie,"http://www.androidtutorialpoint.com/wp-content/uploads/2016/09/Beauty.jpg"));
  
      }
  
      private void initializeAdapter(){
          RVAdapter adapter = new RVAdapter(persons);
          rv.setAdapter(adapter);
      }
  
  }
  </code></pre>