title: Android write file does nothing
body: <p>I have a program where I want to save what the user entered for use in later runs. I am currently trying to save it to a text file. I can run the program fine and everything seems to work, but at the end I check the file and its untouched. Here is the code:</p>
  
  <pre><code>public void onClick(View v) 
      {
          LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
          View layout = inflater.inflate(R.layout.activity_tax_popup, (ViewGroup) findViewById(R.id.taxWindow), false);
  
          String filename = "tax.txt";
          boolean isEnabled = layout.findViewById(R.id.taxBox).isEnabled();
          String enable = String.valueOf(isEnabled);
          String taxPercent = layout.findViewById(R.id.enterTax).toString();
          FileOutputStream fos;
  
          try 
          {
              fos = openFileOutput(filename, Context.MODE_PRIVATE);
              fos.write(enable.getBytes());
              fos.write(taxPercent.getBytes());
              fos.close();
          } 
          catch (Exception e) 
              {e.printStackTrace();}
  
          pw.dismiss();       
      }
  </code></pre>
  
  <p>How can I change it to write to a file? Also if anyone knows a better way to save data between runs I'm open to suggestions.</p>