Recursive method to search for a specific folder
<p>I have a recursive method like this: </p>

<pre><code>public String FolderSearch(File SrcFolder, String foldername){      

         File[] dirsInRoot = SrcFolder.listFiles();

         for(int i=0;i&lt;dirsInRoot.length;i++){
             String delimiter = "/";
             String [] sfolders = dirsInRoot[i].getName().toUpperCase().split(delimiter);
             if(sfolders[sfolders.length-1].compareTo(foldername.toUpperCase()) == 0){ 
                 return dirsInRoot[i].getPath();
             } else {
                 File temp = dirsInRoot[i]; 
                 String ret = FolderSearch(temp,foldername);
                 if(ret != null) return ret;
             }               
         }          
        return null;            
    }
</code></pre>

<p>Which is been called from this method here:</p>

<pre><code>public String searchForBluetoothFolder() {

    File root = sdCard; 
    String btFolder = FolderSearch(root,"bluetooth");

    if(btFolder == null) {
        new ErrorDialog(context, "No Folder", "couldn't find bt folder", "Exit", 2); 
    }
    return btFolder;        
}
</code></pre>

<p>This method is being called at this point here:</p>

<pre><code>try {
     String bluetoothFile = searchForBluetoothFolder();
     File bluetoothFolder = new File(bluetoothFile);
}catch(Exception e) {   
     Log.e("Exception: ", e.getMessage()); 
}
</code></pre>

<p>Which is throwing an exception, in LogCat the <code>e.getMessage()</code> method only returns <code>null</code></p>

<p>I suspect that the exception is thrown because the return value from the recursive method is <code>null</code>. But why doesn't the recursive method continues in the <code>for-loop</code>? </p>
