title: Kotlin: How to create/append file (and share)
body: <p>I have a list of arrays of data in my app that I would now like to write to a file (csv) and use a 3rd party app (such as email) to share this csv file. I have had no luck finding any helpful resources for creating, finding the file path for, and appending to a file in Kotlin. Does anyone have experience with this or have examples to point to? Just to get started I'm trying to write the header and close the file so I can see that it is correctly writing.</p>
  
  <p>This is what I have for now:</p>
  
  <pre><code>val HEADER = "ID, time, PSI1, PSI2, PSI3, speed1, speed2, temp1, temp2"
  val filename = "export.csv"
  
  var fileOutStream : FileOutputStream = openFileOutput(filename,Context.MODE_PRIVATE)
  
  try {
      fileOutStream.write(HEADER.toByteArray())
      fileOutStream.close()
  }catch(e: Exception){
      Log.i("TAG", e.toString())
  }
  </code></pre>
  
  <p>It doesn't throw the exception, but I cannot find the file in the file system. I'm using a physical tablet for testing/debug. I've checked the com.... folder for my app.</p>