title: recieving "java.lang.NullPointerException: error while geting list of files in android
body: <p>I have problem when I want to get my fonts form my dataBase.</p>
  
  <p>This is my Activity :</p>
  
  <pre><code>public class Arrange_fur_secondaryActivity extends AppCompatActivity {
      @Override
      protected void onCreate(Bundle saveInstanceState) {
          super.onCreate(saveInstanceState);
          setContentView(R.layout.activity_warning);
  
          String path = Environment.getExternalStorageDirectory().toString()+"/database";
          Log.d("FilesFilesFiles", "PathPathPath: " + path);
          File directory = new File(path);
          File[] files = directory.listFiles();
          Log.d("FilesFilesFilesFiles", "SizeSizeSizeSize: "+ files.length);
          for (int i = 0; i &lt; files.length; i++)
          {
              Log.d("Files", "FileName:" + files[i].getName());
          }
      }
  }
  </code></pre>
  
  <p>And My Logcat Error :</p>
  
  <pre><code>**019-11-12 21:36:25.504 24221-24221/sungjusin.gatag3 E/AndroidRuntime: FATAL EXCEPTION: main
      Process: sungjusin.gatag3, PID: 24221
      java.lang.RuntimeException: Unable to start activity ComponentInfo{sungjusin.gatag3/sungjusin.gatag3.Arrange_fur_secondaryActivity}: java.lang.NullPointerException: Attempt to get length of null array
          at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2913)
          at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3048)
          at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
          at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
          at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
          at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1808)
          at android.os.Handler.dispatchMessage(Handler.java:106)
          at android.os.Looper.loop(Looper.java:193)
          at android.app.ActivityThread.main(ActivityThread.java:6669)
          at java.lang.reflect.Method.invoke(Native Method)
          at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
          at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
       Caused by: java.lang.NullPointerException: Attempt to get length of null array
          at sungjusin.gatag3.Arrange_fur_secondaryActivity.onCreate(Arrange_fur_secondaryActivity.java:34)
          at android.app.Activity.performCreate(Activity.java:7136)
          at android.app.Activity.performCreate(Activity.java:7127)
          at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1271)
          at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2893)
          at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3048) 
          at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78) 
          at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108) 
          at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68) 
          at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1808) 
          at android.os.Handler.dispatchMessage(Handler.java:106) 
          at android.os.Looper.loop(Looper.java:193) 
          at android.app.ActivityThread.main(ActivityThread.java:6669) 
          at java.lang.reflect.Method.invoke(Native Method) 
          at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493) 
          at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858) 
  2019-11-12 21:36:25.527 24221-24221/sungjusin.gatag3 I/Process: Sending signal. PID: 24221 SIG: 9**
  </code></pre>