Android Question Copy file from uri [SOLVED]


Active Member
Licensed User
Longtime User

I am trying to create an application, which through the share menu, receives a uri of a file, then the application copies it to a "safe" directory

I already managed to receive the Uri correctly.

I also managed to correctly extract the path of the file, from the uri

But the copy function says that the origen file cannot be found.

I found this that he sent me to but it doesn't give me any clue to copy the file. or I did not understand.

This is the code

Sub Activity_Resume
    If IsRelevantIntent(Activity.GetStartingIntent) Then
        Dim in As JavaObject = Activity.GetStartingIntent
        Dim uri As String = in.RunMethod("getParcelableExtra", Array("android.intent.extra.STREAM"))
        Log("Uri " & uri)
            Dim FileName As String
            FileName = Uri_Class.GetFileInfoByIndex("_display_name", uri) 'Get the file name
            Log("Name " & FileName)
            Dim OriginPath As String
            OriginPath = GetPathUri(False, uri) 'Get the file path
            Log("OriginPath1 " & OriginPath)
            Dim SafeFolder As String
            SafeFolder = "SafeFolder"
            Dim Destination As String = "file:///" & SafeFolder
            Log("Destinarion " & Destination)
            'OriginPath = OriginPath.SubString2(0, OriginPath.LastIndexOf("/"))
            'Log("OriginPath1 " & OriginPath)
            File.Copy(OriginPath, FileName, File.DirInternal, FileName)
        End Try
    End If
End Sub
Last edited: