If I recall listFiles() can return null if you can't read the directory, but you can stat it to determine it is a directory.  (E.g. x but no r bit.)

Thus we prefer something like:

  File[] children = fileOrFolder.listFiles();
  if (children != null) {
    for (File child : children)
      deleteRecursive(child);
  }

And since listFiles() returns null when the fileOrFolder is not a directory, you an also skip the isDirectory() test.