title: How to open a directory from intent in android?
body: <p>I am trying to open a directory with the help of an intent to show the user what is the content inside that folder but I am unable to do so,
  but I don't know why the folder won't open and I get this &quot;Can't use this folder&quot; on the file manager.</p>
  <p><a href="https://i.stack.imgur.com/4gSwH.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/4gSwH.png" alt="enter image description here" /></a></p>
  <pre><code>               open.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View view) {
  
                  String path = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOCUMENTS) + &quot;/&quot; + &quot;XYZ&quot;;
                  Uri uri = Uri.parse(path);
                  Toast.makeText(MainActivity.this, &quot;&quot;+path, Toast.LENGTH_SHORT).show();
  
                  openDirectory(uri);
  
              }
          });
  
  </code></pre>
  <p>The method</p>
  <pre><code>public void openDirectory(Uri uriToLoad){
          // Choose a directory using the system's file picker.
          int result = 1;
  
          Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE);
  
          // Optionally, specify a URI for the directory that should be opened in
          // the system file picker when it loads.
          intent.putExtra(DocumentsContract.EXTRA_INITIAL_URI, uriToLoad);
  
          startActivityForResult(intent, result);
      }
  </code></pre>
  <p>I want to open the folder XYZ after clicking on the button</p>