krnbatta / android-file-dialog

Automatically exported from code.google.com/p/android-file-dialog
0 stars 0 forks source link

Exception in getDirImpl if the list of files in the start directory is empty #4

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
At least with Android 2.2, f.listFiles() returns null if there are no child 
files in the selected directory (for example "/sdcard" on the emulator.

So (File file : files) will fail with a NullPointerException in this case. You 
could add before a guard like: 
if (files != null) ...

Then the dialog will work OK. I don't know if the origin of this problem is an 
issue in Android 2.2 or just a protection worth to be added to the dialog.

In Java listFiles() returns an empty list (not null) if there is nothing in the 
directory, but I don't know if the "/sdcard" path exist on the emulator by 
default.

Original issue reported on code.google.com by herve.gi...@gmail.com on 4 Aug 2011 at 8:49

GoogleCodeExporter commented 9 years ago
BTW "/sdcard" is just an example of course ;)

Original comment by herve.gi...@gmail.com on 4 Aug 2011 at 8:52

GoogleCodeExporter commented 9 years ago
Thanks a lot for the bug report, i'll try to fix all the bugs today

Original comment by alexande...@gmail.com on 18 Aug 2011 at 6:37

GoogleCodeExporter commented 9 years ago
The bug is fixed, 

herve.gi...@gmail.com thank you very much for the report and your help :)

Original comment by alexande...@gmail.com on 18 Aug 2011 at 7:43

GoogleCodeExporter commented 9 years ago
thanks for the fix. Happy to have helped ;)

Original comment by herve.gi...@gmail.com on 20 Aug 2011 at 2:19