title: Empty RecyclerView while reading mp3 files from android device
body: <p>I have included the permission to read external storage in manifest</p>
  
  <p>PlaylistActivity.java</p>
  
  <pre><code>public class PlaylistActivity extends AppCompatActivity {
  
      private RecyclerView recyclerView;
      private SongsAdapter songsAdapter;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_playlist);
          recyclerView=(RecyclerView)findViewById(R.id.playlistactivityrecyclerview);
          songsAdapter=new SongsAdapter();
          recyclerView.setLayoutManager(new LinearLayoutManager(getApplicationContext()));
          recyclerView.setAdapter(songsAdapter);
          Toast.makeText(getApplicationContext(),"Hi",Toast.LENGTH_LONG).show();
      }
  }
  </code></pre>
  
  <p>SongsAdapter</p>
  
  <pre><code>public class SongsAdapter extends RecyclerView.Adapter&lt;SongsAdapter.MyViewHolder&gt;{
  
     SongsManager songsManager;
      String MEDIA_PATH = Environment.getExternalStorageDirectory() + "";
      ArrayList&lt;HashMap&lt;String, String&gt;&gt; songList=new ArrayList&lt;&gt;();;
  
  
  
      @Override
      public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
          View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.list_item, parent, false);
          return new MyViewHolder(view);
  
      }
  
      @Override
      public void onBindViewHolder(MyViewHolder holder, int position) {
          songsManager=new SongsManager();
  
           songList =songsManager.getPlayList(MEDIA_PATH);
          if (songList != null) {
              for (int i = 0; i &lt; songList.size(); i++) {
                  String fileName = songList.get(i).get("file_name");
                  String filePath = songList.get(i).get("file_path");
                  holder.textView.setText(fileName);
  
              }
  
          }
  
  
      }
  
      @Override
      public int getItemCount() {
          return songList.size();
      }
  
      public class MyViewHolder extends RecyclerView.ViewHolder  implements View.OnClickListener {
          private TextView textView;
  
          public MyViewHolder(View itemView){
              super(itemView);
              textView=(TextView)itemView.findViewById(R.id.listitemtextview);
  
          }
  
          @Override
          public void onClick(View v) {
  
          }
      }
  
  }
  </code></pre>
  
  <p>SongsManager</p>
  
  <pre><code>public class SongsManager {
  
  
      public ArrayList&lt;HashMap&lt;String, String&gt;&gt; getPlayList(String rootPath) {
          ArrayList&lt;HashMap&lt;String, String&gt;&gt; fileList = new ArrayList&lt;&gt;();
  
          try {
              File rootFolder = new File(rootPath);
              File[] files = rootFolder.listFiles(); //here you will get NPE if directory doesn't contains  any file,handle it like this.
              for (File file : files) {
                  if (file.isDirectory()) {
                      if (getPlayList(file.getAbsolutePath()) != null) {
                          fileList.addAll(getPlayList(file.getAbsolutePath()));
                      } else {
                          break;
                      }
                  } else if (file.getName().endsWith(".mp3")) {
                      HashMap&lt;String, String&gt; song = new HashMap&lt;&gt;();
                      song.put("file_path", file.getAbsolutePath());
                      song.put("file_name", file.getName());
                      fileList.add(song);
                  }
              }
              return fileList;
          } catch (Exception e) {
              return null;
          }
      }
  }
  </code></pre>
  
  <p>I am trying to read all mp3 files from my android device.The reading code works.But when i use recyclerview it does not get display on it.I have included the read external storage permission in manifest.Please help</p>