title: Android Java: File seems to be locked after creating/writing
body: <p>I am .NET developer for many years (10 years) and I am programming android java the first time in my free time.
  The application I am programming is an app for input data of some course participant. The  course instructor  inputs some course number (which is part of the file name) and each participant enters his name and birthdate. So I have two activities. One for the instructor, one for the participant. </p>
  
  <p>The first Activity creates the File in the download folder, the second one append he participant data at the end of the CSV file. So far no problem for a C#.net developer, because java syntax is like c# syntax. The App was programmed in one week.</p>
  
  <p>But now during testing following problem occurs: The generated csv file can be viewed on android in the android file explorer and the content can be opened in android. But if I connect the smartphone to the desktop pc, the csv file is not shown in the windows file explorer.</p>
  
  <p>The file is only shown in the windows file explorer, if I reboot the smartphone. It seems that the code does not free the resource, although I close the file with the close method and end the application.</p>
  
  <p>What do I make wrong in the following code:</p>
  
  <pre><code>public boolean CreateFile() {
      boolean OK = false;
  
      File file = new File(_FileName);
      if (!file.exists()) {
              try {                   
                      if (file.createNewFile())
                      {
                          _StatusText.setText( "Status:Leere Kurs-Teilnehmer-Datei angelegt:\n" + _FileName + ".csv");
                          OK = true;
                      }
                      else
                          _StatusText.setText("Status:Datei nicht angelegt");                     
              } catch (Exception e) {
                  _StatusText.setText("Status:Fehler:" + e.toString());
              }
              finally {
                  return OK;
              }
      }
      else
      {
          _StatusText.setText("Status:Bereits Vorhandene Kursliste wird verwendet");
          return true;
      }
  }
  </code></pre>
  
  <p>This is the code for adding lines to the end of csv file:</p>
  
  <pre><code>public static void AppendDataToCSV(String Filename, String Nachname, String Vorname, String Datum) throws IOException {
      FileWriter out = null;
      try {
          StringBuilder textline = new StringBuilder();
          textline.append(Nachname)
          .append(";")
          .append(Vorname)
          .append(";")
          .append(Datum)
          .append("\n");
  
          out = new FileWriter(Filename, true);
          out.write(textline.toString());
      }
      finally {
          if (out != null)
              out.close();            
      }
  }
  </code></pre>
  
  <p>This is the code for finishing the application:</p>
  
  <pre><code>private void ButtonEndeClick(){
      _StatusText.setText("Ende");
      finish();
      System.exit(0);
  }
  </code></pre>
  
  <p>Please, let me know how to be sure that all ressorces are freed after app is closed.</p>
  
  <p>Many thanks to you for your help :-)</p>