title: How to use MediaStore with scoped storage to store files in Android10
body: <p>Im trying to develop an android-lib to store files in /sdcard/{Environment.DIRECTORY_*} after Android 10 has locked everything with its scoped storage. </p>
  
  <p>I tried <code>context.getExternalFilesDir(Environment.DIRECTORY_PICTURES)</code> which is giving me <code>/sdcard/Android/data/my.company.namespace/files/Pictures</code>. I was assuming I could use the MediaStore to scan this Folder and gallery Apps will show Pictures from there. Unfortunately, It doesn't...</p>
  
  <p>I'm reading the docs for hours, but cannot find a comprehensive guide on how to do this.</p>
  
  <p>For Example:</p>
  
  <p><code>MediaStore.Images.Media.insertImage(ContentResolver, Bitmap, String, String)</code> is <a href="https://developer.android.com/reference/android/provider/MediaStore.Images.Media.html#insertImage(android.content.ContentResolver,%20java.lang.String,%20java.lang.String,%20java.lang.String)" rel="nofollow noreferrer">deprecated</a> and links to <a href="https://developer.android.com/reference/android/provider/MediaStore.MediaColumns.html#IS_PENDING" rel="nofollow noreferrer">MediaStore.MediaColumns.IS_PENDING</a> which doesn't say a word on how to use it. 
  If I look inside the code, It uses a lot of classes which are non-existant, like <code>PendingParams</code>or <code>PendingSession</code> and even If I copy them they still use deprecated methods.</p>
  
  <p>Is there a comprehensive guide, how to use MediaStore to save Files at their respective locations?</p>
  
  <p>Say I want to store a custom image format (image/wsq) in <code>/sdcard/Pictures</code>. Or a custom binary file in <code>/sdcard/Documents</code>. It doesn't matter if other apps could access it or not. </p>
  
  <p>How do I do it with <code>MediaStore</code>?</p>