title: Unable to list parent directory from file path
body: <p>In my code am trying to collect all video file in list and warp it inside there parent directory and display it inside <code>recycler view</code>, And while displaying i get a folder name <code>0</code> i don't understand where the <code>0</code> folder comes from.</p>
  <p>And the <code>0</code> folder list all files inside my storage, And those file are perfectly warped inside their respective folder.</p>
  <blockquote>
  <p>and here is a screen shot of the folder zero.</p>
  </blockquote>
  <p><a href="https://i.stack.imgur.com/TBofv.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/TBofv.jpg" alt="enter image description here" /></a></p>
  <p><strong>code</strong></p>
  <pre><code>@Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
  
      foldersList = new ArrayList&lt;&gt;();
      folderpath = new ArrayList&lt;&gt;();
  
      recyclerView = findViewById(R.id.recyclerView);
      recyclerView.setHasFixedSize(true);
      recyclerView.setLayoutManager(new LinearLayoutManager(this));
      parseAllVideo();
      getUniqueFolders();
      adapter = new FolderAdapter(this, foldersList);
      recyclerView.setAdapter(adapter);
      adapter.notifyDataSetChanged();
  
  }
  
  private void parseAllVideo() {
      try {
          String[] proj = {
                  MediaStore.Video.Media._ID,
                  MediaStore.Video.Media.DATA};
  
          Cursor videocursor = this.getContentResolver().query(MediaStore.Video.Media.EXTERNAL_CONTENT_URI, proj, null, null, null);
          if (videocursor != null) {
              if (videocursor.moveToFirst()) {
                  int path_index = videocursor.getColumnIndexOrThrow(MediaStore.Video.Media.DATA);
                  do {
                      String filepath = videocursor.getString(path_index);
                      String folder_path = MyUtils.getParentDirPath(filepath);
                      File file = new File(filepath);
                      if (file.exists()) {
  
                      }
                      folderpath.add(folder_path);
                  } while (videocursor.moveToNext());
              }
              videocursor.close();
          }
  
      } catch (Exception e) {
          e.printStackTrace();
      }
  }
  
  private void getUniqueFolders() {
      List&lt;String&gt; newList = new ArrayList&lt;&gt;(new HashSet&lt;&gt;(folderpath));
      Collections.sort(newList);
      for (int i = 0; i &lt; newList.size(); i++) {
          String folder_name = newList.get(i).substring(newList.get(i).lastIndexOf(&quot;/&quot;) + 1);
          FolderModel folder = new FolderModel(folder_name, newList.get(i));
          Log.d(TAG, &quot;base file = &quot; + folder);
          foldersList.add(folder);
      }
  
  }![enter image description here](https://i.stack.imgur.com/rgQrz.jpg)
  </code></pre>
  <p>Here is what am trying to archive, the file in the internal folder is displayed as thumbnail by (glide, bit...) but with my code the <code>0</code> folder contains all file in my storage,</p>
  <p>Here is what i want. <a href="https://i.stack.imgur.com/xR5Yc.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/xR5Yc.jpg" alt="enter image description here" /></a></p>