title: How to open any type of file from recycler view adapter class?
body: <p>What i'm trying to do is when the file is successfully downloaded it should be automatically opened from the file path but now here the problem is that i need to fire the path from my recycler view adapter class when i try to do that it generates an exception
  Take a look at my adapter class:
  Here i'm using a class with the adapter which will basically download the file from the url but when i try to fire the intent for opening the file from download class it just goes to error something went wrong.</p>
  
  <pre><code>public class Filelistadapter extends RecyclerView.Adapter&lt;Filelistadapter.ProjectViewHolder&gt;{
      private String url;
  
      private ArrayList&lt;Taskmsg&gt; dataList;
  
  
      Context mContext;
  
  
      public Filelistadapter(ArrayList&lt;Taskmsg&gt; dataList, Context mContext) {
          this.dataList = dataList;
          this.mContext=mContext;
  
      }
  
      @Override
      public ProjectViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
          LayoutInflater layoutInflater = LayoutInflater.from(parent.getContext());
          View view = layoutInflater.inflate(R.layout.file_item, parent, false);
          return new ProjectViewHolder(view);
      }
  
      @Override
      public void onBindViewHolder(ProjectViewHolder holder, int position) {
          String fname=dataList.get(position).getFilename();
          holder.txtfilename.setText(fname);
          holder.download.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                  url="http://pms.cloudester.com/task_doc/"+fname;
                  new DownloadFile().execute(url);
  
              }
          });
  
  
      }
  
  
  
      @Override
      public int getItemCount() {
  
          return dataList.size();
  
      }
  
      class ProjectViewHolder extends RecyclerView.ViewHolder {
  
          TextView txtfilename;
          Button download;
          ProjectViewHolder(View itemView) {
              super(itemView);
              txtfilename = (TextView) itemView.findViewById(R.id.tvfilename);
              download=itemView.findViewById(R.id.actionButton);
  
          }
      }
  
      private class DownloadFile extends AsyncTask&lt;String, String, String&gt; {
  
          private ProgressDialog progressDialog;
          private String fileName;
          private String folder;
          private boolean isDownloaded;
  
          /**
           * Before starting background thread
           * Show Progress Bar Dialog
           */
          @Override
          protected void onPreExecute() {
              super.onPreExecute();
              this.progressDialog = new ProgressDialog(mContext);
              this.progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
              this.progressDialog.setCancelable(false);
              this.progressDialog.show();
          }
  
          /**
           * Downloading file in background thread
           */
          @Override
          protected String doInBackground(String... f_url) {
              int count;
              try {
                  URL url = new URL(f_url[0]);
                  URLConnection connection = url.openConnection();
                  connection.connect();
                  // getting file length
                  int lengthOfFile = connection.getContentLength();
  
  
                  // input stream to read file - with 8k buffer
                  InputStream input = new BufferedInputStream(url.openStream(), 8192);
  
                  String timestamp = new SimpleDateFormat("yyyy.MM.dd.HH.mm.ss").format(new Date());
  
                  //Extract file name from URL
                  fileName = f_url[0].substring(f_url[0].lastIndexOf('/') + 1, f_url[0].length());
  
                  //Append timestamp to file name
                  fileName = timestamp + "_" + fileName;
  
                  //External directory path to save file
                  folder = Environment.getExternalStorageDirectory() + File.separator + "pms/";
  
                  //Create androiddeft folder if it does not exist
                  File directory = new File(folder);
  
                  if (!directory.exists()) {
                      directory.mkdirs();
                  }
  
                  // Output stream to write file
                  OutputStream output = new FileOutputStream(folder + fileName);
  
                  byte data[] = new byte[1024];
  
                  long total = 0;
  
                  while ((count = input.read(data)) != -1) {
                      total += count;
                      // publishing the progress....
                      // After this onProgressUpdate will be called
                      publishProgress("" + (int) ((total * 100) / lengthOfFile));
  
  
                      // writing data to file
                      output.write(data, 0, count);
                  }
  
                  // flushing output
                  output.flush();
  
                  // closing streams
                  output.close();
                  input.close();
                  return "Downloaded at: " + folder + fileName;
              } catch (Exception e) {
                  Log.e("Error: ", e.getMessage());
              }
              return "Something went wrong";
          }
  
          /**
           * Updating progress bar
           */
          protected void onProgressUpdate(String... progress) {
              // setting progress percentage
              progressDialog.setProgress(Integer.parseInt(progress[0]));
          }
  
  
          @Override
          protected void onPostExecute(String message) {
              // dismiss the dialog after the file was downloaded
              this.progressDialog.dismiss();
  
              // Display File path after downloading
              Toast.makeText(mContext,
                      message, Toast.LENGTH_LONG).show();
          }
      }
  }
  </code></pre>