title: progressDialog not dismissing after progressDialog.dismiss();
body: <p>I have a method which gets a string from a file and puts it inside String variable named username, because the reading from the file takes time, I want a progressDialog to appear untill the function is finished, the preogress dialog does appear but is not dismissed when I use progressDialog.dismiss();</p>
  
  <p>This is the code:</p>
  
  <pre><code>public String loadUserFromFile(){
  
      progressDialog = new ProgressDialog(this);
      progressDialog.setTitle("Please wait...");
      progressDialog.setMessage("Loading User");
      progressDialog.show();
  
      String username = "default";
      String fileName = "savedUserFile.txt";
      FileInputStream fis;
      try {
          fis = openFileInput(fileName);
          InputStreamReader inputStreamReader = new InputStreamReader(fis);
          BufferedReader br = new BufferedReader(inputStreamReader);
          username = br.readLine();
          br.close();
      } catch (FileNotFoundException e) {
          e.printStackTrace();
      } catch (IOException e) {
          e.printStackTrace();
      }
      username = username.replaceAll("\\s+","");
      progressDialog.dismiss();
      return username;
  }
  </code></pre>