At the first step, it depends on the android version of the system which the app is running in. As far as I know , from the api level 28 , a subject is introduced that is "Scoped storage". Since then , the way of accessing the external storage changed. There are several documents in google written about this. My personal opinion is to read them to get the whole information about it
I've checked many of dem isn't working for me I'm tryna upload the file to php with retrofit multipart but I'm not sure I'm getting the part correctly
What do you wanna do?? You want the user to pick for example a picture so that you get the uri. You want to the the uri of some files in a special directory?? .....
Yes I want to get the uri
There are several alternatives for that. One of them is to use ACTION_OPEN_DOCUMENT_TREE that opens sth like a file explorer for the user then you switch to the directory you want. Then the user should press the button and agree. Then , you are able to get the uri of all the contents of that directory. Another alternative is to open the gallery and pick an image so that you have the uri of that image. (You can find the solution here) If you wanna pick another media (audio , video , download , etc ) , you can find its solution in stackoverflow and all of them are using Intent class. Another alternative is to load all the images by from the gallery by using the MediaStore class so that you have the uri of any of them. (You can do this not only with images also with music , downloads , videos). If your app is sth like a file explorer that should access the whole external storage and you wanna get the uri of each file you want , I saw the solution in the google documents but I have forgotten it.
Обсуждают сегодня