title: How to force a MediaStore update for a file using only its Content Uri
body: <p>In <strong>Android Q</strong> the field <a href="https://developer.android.com/reference/android/provider/MediaStore.MediaColumns.html#DATA" rel="noreferrer">MediaStore.Files.FileColumns.DATA</a> <strong>has been deprecated</strong>, and <strong>may be Null or apps have no rights to read it</strong> when targeting such OS version, so will be preferable to work using only a file’s content Uri.</p>
  
  <p>Since the <a href="https://developer.android.com/reference/android/media/MediaScannerConnection" rel="noreferrer">MediaScannerConnection</a> only accepts file paths, I found that for <strong>Android Q</strong> this is no longer an option.</p>
  
  <p>What would be the way to force an <strong>automatic</strong> MediaStore update/re-scan of a single file, without knowing its real path and <strong>using only its Uri</strong>? The intention is not to even try to find the real path and rely only in the Uri. </p>
  
  <p>Consider that the Uri to force the update is a media content Uri <strong>(not a SAF Uri</strong>).<br /> 
  Example: content://media/external/images/media/123</p>
  
  <p><strong>The solution must not be to re-scan the entire storage or un-mount / mount the storage again, as this will have a high performance hit in our workflow and will make it completely unusable.</strong> </p>
  
  <p>And because the intention is to use only the Uri, then to avoid forcing a scan of any specific directory of files, which would also have an impact if it contains lots of files, and implies that a real directory path must be resolved from the Uri, which is not an option.</p>
  
  <p><strong>UPDATE:</strong></p>
  
  <p>We have tried <strong>with unsuccessful results</strong> the <a href="https://developer.android.com/reference/android/content/ContentResolver#refresh(android.net.Uri,%20android.os.Bundle,%20android.os.CancellationSignal)" rel="noreferrer">ContentResolver.refresh</a> method introduced in Android O, yet this method doesn't do any refresh at all when it comes to a media content Uri in a format such as: content://media/external/images/media/123</p>
  
  <pre><code>final ContentResolver resolver = context.getContentResolver();
  resolver.refresh(uri, null, null);
  </code></pre>