title: Opening file in read-only mode through Intent
body: <p>I'm currently making an app which download a file from a server and then open it.</p>
  
  <p>I succeed to launch intent and open the file. However, I need sometimes to open this file in read-only mode, I did not succeed so far.</p>
  
  <p>Here is my code :</p>
  
  <pre><code>var uri = FileProvider.getUriForFile(context!!, BuildConfig.APPLICATION_ID + ".fileprovider", lastSavedFile)
  var openingDocumentIntent = Intent()
  var fileMime = context!!.contentResolver.getType(uri)
  
  openingDocumentIntent.action = Intent.ACTION_VIEW
  openingDocumentIntent.setDataAndType(uri, fileMime)
  openingDocumentIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
  
  context?.startActivity(openingDocumentIntent)
  </code></pre>
  
  <p>I have tried many ways :</p>
  
  <ul>
  <li>FLAG_GRANT_WRITE_URI_PERMISSION  </li>
  <li>Intent.ACTION_VIEW and Intent.ACTION_EDIT</li>
  </ul>
  
  <p>Moreover, I have seen many people complaining about Microsoft Apps such as Word which does not handle opening file in Write mode but only in Read-Only mode.</p>
  
  <p>Does anyone knows how to open a file in read-only mode? (no matter which app opens it)
  And the opposite... How to open a file in write mode with Microsoft App? (e.g Word)</p>