title: Android: How to get real path from Uri for Any file
body: <p>I want the real path from uri of a file type Any, I have the code for an image file but it does not work for what I want.</p>
  
  <p>My file I want is a CSV file:</p>
  
  <pre><code>private fun getRealPathFromURI(contentURI: Uri, context: Context): String {
              val result: String
              val cursor = context.contentResolver.query(contentURI, null, null, null, null)
              if (cursor == null) { // Source is Dropbox or other similar local file path
                  result = contentURI.path
              } else {
                  cursor.moveToFirst()
                  val idx = cursor.getColumnIndex(MediaStore.Images.ImageColumns.DATA)
                  result = cursor.getString(idx)
                  cursor.close()
              }
              return result
          }
  </code></pre>
  
  <p><strong>EDIT:</strong>
  RESOLVED:</p>
  
  <pre><code>//On recupere le chemin du fichier ou manuellement ou par un picker
          val path = data.data
  
          //On ouvre le fichier du chemin
          val `is` = context.contentResolver.openInputStream(path)
  
          //Puis on le lis
          val reader = BufferedReader(InputStreamReader(`is`))
  </code></pre>