title: Android Kotlin (beginner) - using File() with Uri returned from ACTION_GET_CONTENT
body: <p>I'm very new to both Android and Kotlin/Java. I don't understand why my <code>File()</code> method gets the error:</p>
  
  <blockquote>
    <p>none of the following functions can be called with the arguments supplied.  </p>
  </blockquote>
  
  <p>I thought that what I have put should return the Uri obtained from the <code>ACTION_GET_CONTENT</code> and that this should be enough to construct the File object. I'm trying to make an app that will load a txt file and display it. I'm hoping it's a really simple mistake somewhere:</p>
  
  <pre><code>fun showFileDialog() {
      val fileintent = Intent(Intent.ACTION_GET_CONTENT)
      fileintent.setType("text/plain")
      fileintent.addCategory(Intent.CATEGORY_OPENABLE)
      startActivityForResult(fileintent, FILE_SELECT_CODE)
  }
  
  override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { 
      super.onActivityResult(requestCode, resultCode, data)
      if(requestCode == FILE_SELECT_CODE &amp;&amp; resultCode == Activity.RESULT_OK) {
          val selectedfile = File(data!!.data)
          val readData = FileInputStream(selectedfile).bufferedReader().use { it.readText
              textView.text = readData
          }
      }
  }
  </code></pre>
  
  <p>I don't know if the rest of the posted code works either, but this error will not let me build it to test it. TIA for any help/pointers</p>
  
  <p>RESOLVED:</p>
  
  <p>The first answer explained why I was getting the error (hence, answering my question)</p>
  
  <p>After getting help from second answer and comment below, (and more searching on SO; see links below) I changed my last 3 lines of code to:</p>
  
  <pre><code>val input: InputStream = getContentResolver().openInputStream(data!!.data)
  val inputAsString = input.bufferedReader().use { it.readText() }
  textView.setText(inputAsString)
  </code></pre>
  
  <p>and this is working well. Thank you!</p>
  
  <p>LINKS:</p>
  
  <p><a href="https://stackoverflow.com/questions/5657411/android-getting-a-file-uri-from-a-content-uri">Android: Getting a file URI from a content URI?</a></p>
  
  <p><a href="https://stackoverflow.com/questions/39500045/in-kotlin-how-do-i-read-the-entire-contents-of-an-inputstream-into-a-string">In Kotlin, how do I read the entire contents of an InputStream into a String?</a></p>