I have implemented ActvityResults API to get an image from gallery (or) directly from camera.
for taking a image from camera it's simple
create a file obj in your app's local directory.
create a URI for file obj
using ActivityResults API, send this uri in the ActivityResultLauncher (This will automatically write the image that you capture to the URI)
just store the URI as String in DB and use it (no permission/access issues)
but when selecting an image using ActivityResult API contracts from Storage,
It returns a URI.
If I store this URI in my DB... I cant access it because the image file isn't local to my app and therefore I don't have permission to access it
so I'm looking for a method to copy this URI's content into a File obj (which will be created in the app's local directory.
So that I can store the file's URI as string in my DB
P.S [ many questions answering this are at least 7 years old and are in JAVA (they use the cursor API, so if you have a solution much simpler than that please share your knowledge & expertise ) ]