title: Saving media file path or URI to SQLite and getting it, best practice
body: <p>My goal is to:</p>
  <ul>
  <li>Save media file to External Storage (in my case it's photo).</li>
  <li>Get file path or URI of saved data.</li>
  <li>Save it to SQLite (either file path or content URI or smth else).</li>
  <li>Be able to get correct URI to this content at any point in the future.</li>
  </ul>
  <p>It's very similar to what other very popular application do - they create their directory in 'Pictures' folder and store there photos and use them in their applications while they're also available for viewing using gallery/file explorer etc.</p>
  <p>As I understand recommended way to save media content (image, f.e.) is to use <code>MediaStore</code> API and as a result I get content URI, which I can use later.
  But then I read that these content URIs might be changed after re-scan of Media happens, so it looks it's not reliable. (For example if SD card is used and it's taken out and inserted again)</p>
  <p>At the same time usage of absolute file paths is not recommended and there's tendency to deprecate APIs which use absolute file paths to work with External Storage. So it doesn't look reliable either.</p>
  <p>I can only imagine the following solution:</p>
  <ul>
  <li>Use unique auto-generated file name while saving (like UUID).</li>
  <li>When I need to get content URI (f.e. want to render photo in <code>ImageView</code>) - I can use <code>ContentResolver</code> and search for content URI using file name filter.</li>
  </ul>
  <p>Problem with this approach is that I have a lot of photos (gallery) and querying it using <code>ContentResolver</code> can affect performance significantly.</p>
  <p>I feel like I'm over complicating things and missing something.</p>