title: Nearby Connections API: Cannot access received file on Android 10
body: <p>I am following <a href="https://developers.google.com/nearby/connections/android/exchange-data" rel="nofollow noreferrer">this guide</a> with the goal of transferring an image file which on the receiver side should be uploaded via a REST API.</p>
  
  <p>Android 10 blocks access to public folders like the 'Downloads' folder in which all received files from Nearby Connections API are stored in, in a 'Nearby' folder.</p>
  
  <p><code>File payloadFile = filePayload.asFile().asJavaFile();</code></p>
  
  <p>I have a <code>Payload</code> object, and as the guide suggests the code above should get the file. Unfortunately the above code returns null when targeting api 29 and running on an Android 10 device. Works fine on earlier Android versions. </p>
  
  <p>I can get the ParcelFileDescriptor by doing <code>File payloadFile = filePayload.asFile().asParcelFileDescriptor();</code> but not sure how to access the file then?</p>
  
  <p>Via the <code>ParcelFileDescriptor</code> I have tried reading the file in the following ways but I always get some kind of permission or bad access exception:</p>
  
  <p><code>BitmapFactory.decodeStream(FileInputStream(payloadFileDescriptor.fileDescriptor))</code>
  or
  <code>BitmapFactory.decodeFileDescriptor(payloadFileDescriptor.fileDescriptor)</code></p>
  
  <p>The file is stored correctly in the Downloads folder as I can see and open it via a file browser app.</p>
  
  <p>Also tried accessing via a content resolver (<code>MediaStore.Downloads.EXTERNAL_CONTENT_URI</code> and <code>MediaStore.Images.EXTERNAL_CONTENT_URI</code>) but no luck.</p>
  
  <p>A note here is that the files are save with no extension, so maybe that's why Mediastore can't find anything?</p>
  
  <p>I use "com.google.android.gms:play-services-nearby:17.0.0".</p>
  
  <p>As mentioned I really want to receive a file and upload it. Is this totally impossible with Nearby Connections API on Android 10?</p>