Create URI to a file using android Uri.Builder() function

371 Views Asked by At

I am new to using Uri's to locate files on the emulators storage in android studio.

I have a png file saved in the android emulators data/data/com.domain.appname/files directory. I would like to create the uri for this file using android's Uri.Builder() function. I want to make sure the uri is consctucted correctly, rather than hardocding the path myself, hence using the builder api.

How would i go about doing this? The link the to builder api is https://developer.android.com/reference/kotlin/android/net/Uri.Builder. I have started creating the uri myself below but not sure what to do next.

Context: I am using googles Glance API to show the image in an android homescreen widget. The api asks for a URI parameter.


val uri = Uri.Builder().scheme(ContentResolver.SCHEME_FILE)
          ./*insert rest of Uri builder code*/

0

There are 0 best solutions below