title: How to get all the file's name from asset folder?
body: <p>I have copied some folders to the assets folder. I have many folders inside the assets folder. I want to read all the folders name.</p>
  
  <p>What I am doing is</p>
  
  <pre><code>tx.setOnClickListener(new View.OnClickListener() {
      @Override
      public void onClick(View v) {
          String path = "file:///android_asset/";
  
          Log.d("Files", "Path: " + path);
          File directory = new File(path);
          File[] files = directory.listFiles();
  
          Log.d("Files", "Size: "+ files.length);
  
          for (int i = 0; i &lt; files.length; i++)
          {
              Log.d("Files", "FileName:" + files[i].getName());
          }
  
      }
  });
  </code></pre>
  
  <p>But the error it is showing is </p>
  
  <pre class="lang-none prettyprint-override"><code>java.lang.NullPointerException: Attempt to get length of null array
    at com.example.ashura.browsetest.MainActivity$1.onClick(MainActivity.java:29)
    at android.view.View.performClick(View.java:5246)
  </code></pre>