title: Null exception in Thread
body: <p>Before you search algorithm in the file manager.
  What is wrong? </p>
  
  <pre><code>    import java.io.File;
  
  public class SearchThread extends Thread {
      MainActivity ob = new MainActivity();
      Search ob2 = new Search();
      String searchString = new String();
      String stringDirectory = new String();
      public SearchThread(String string, String directory) {
          searchString = string;
          stringDirectory = directory;
          start();
      }
  
      public void run() {
          File directory = new File(stringDirectory);
          search(directory.listFiles());
      }
      public void search(File[] directory) {
          for(File a : directory) {
              if(a.isDirectory()) {
                  search(a.listFiles());
              } else if(ob2.cutFormat(a.getName()) == searchString) {
                  ob.giveMeString(a.getAbsolutePath());
              }
          }
      }
  }
  </code></pre>
  
  <p>Message in log:</p>
  
  <pre><code>12-21 00:28:40.550  13147-13298/com.example.myproject E/AndroidRuntime﹕ FATAL EXCEPTION: Thread-256
      java.lang.NullPointerException
              at com.example.myproject.SearchThread.run(SearchThread.java:21)
  12-21 00:28:40.558      471-482/? E/SurfaceFlinger﹕ #### captureScreenImplLocked
  </code></pre>
  
  <p>Line number 21: " <code>public void search(File[] directory) {</code>"
  I pass from another class path from where to start as a string, and the string with the name of the item I'm looking for.</p>