Android Question Issues copying image from path returned by ContentChooser

Tyler

Member
Licensed User
Longtime User
Hey, I'm trying to simply get the path to an image chosen by user via the ContentChooser but I keep getting issues when I try to get the image directory and copy using it. Here's the error I'm getting:

B4X:
java.io.FileNotFoundException: /storage/emulated/0/adc/content:/com.android.externalstorage.documents/document/primary%3APictures%2Fhd_0.jpg: open failed: ENOENT (No such file or directory)



I know the image exists and it doesn't seem to work with any others either. The file path is quite strange looking as well... ANY help would be much appreciated! Thanks!
 

Tyler

Member
Licensed User
Longtime User
Can you post the relevant code?

Oops, sorry, here you go:

B4X:
Dim  image As ContentChooser


Sub btnAlbumImg_Click
    image.Initialize("imgChooser")
    image.Show("image/*", "Choose image")
   
End Sub


Sub imgChooser_Result(Success As Boolean, Dir As String, FileName As String)
If Success Then
   Dim Out As OutputStream
        Out = File.OpenOutput(File.DirRootExternal & "/adc", FileName, False)
        Dim Inp As InputStream = File.OpenInput(Dir , FileName)
        File.Copy2(Inp, Out)
        Out.Close
   Else
   ToastMessageShow("No image selected!", True)
   End If

Thanks again!
 
Upvote 0
Top