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.
What I am doing is
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 < files.length; i++) { Log.d("Files", "FileName:" + files[i].getName()); } } }); But the error it is showing is
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)