Can new File() constructor return null on Android?
android, java
Solution
No, a constructor may never return null. A constructor either returns a fully initialised object or throws an exception or error.
Problem
I saw this code in android training center website: ``` boolean hasExternalStoragePrivateFile() { // Get path for the file on external storage. If external // storage is not currently mounted this will fail. File file = new File(getExternalFilesDir(null), "DemoFile.jpg"); if (file != null) { return file.exists(); } return false; } ``` Does that mean that on Android `new File()` can return null? http://developer.android.com/reference/android/content/Context.html#getExternalFilesDir(java.lang.String)