I have the uri of my files. Now I need to get its real path to send them. (the uri is like: "content://some-path").
This is for Android 9
I have the uri of my files. Now I need to get its real path to send them. (the uri is like: "content://some-path").
This is for Android 9
So with Android 9+ you can only use file paths inside you applications private storage area otherwise you have to use URI's and ContentResolver
s
See https://developer.android.com/training/data-storage/files/external-scoped for details of the changes in 9+
So I see three solutions when using Retrofit2
FileDescriptor
from a contentResolver and read the file from the contentResolver, writing it to your App's private storage area. You can then get a Java File Object as normal from this copy of the file. This is similar to stackoverflow.com/a/52814247/3518278 as suggested by ViVekH FileDescriptor
from a contentResolver and read it in to a in memory Byte array. I'm not a Retrofit2 user but I believe you can create Request Body or Multipart part from a Byte array instead of a Java File
object.FileDescriptor
object instead of a File
ObjectNote with the contentResolver
you can query it to get the "Display Name" as the filename part of the Path.