dim uri10 as string="content://0@media/external/file/45"
Dim dm As String = GetPathFromContentResult(uri10)
Log(dm) ' return --- ' /storage/emulated/0/Android/media/com.whatsapp/WhatsApp/Media/WhatsApp Documents/grid_tbl_pos_items.xls
File.Copy("",dm,File.DirInternal,"mdata.xlsx")
End Sub
Sub GetPathFromContentResult(UriString As String) As String
If UriString.StartsWith("/") Then Return UriString 'If the user used a file manager to choose the image
Dim Cursor1 As Cursor
Dim Uri1 As Uri
Dim Proj() As String = Array As String("_data")
Dim cr As ContentResolver
cr.Initialize("")
Log(UriString)
'content://com.android.providers.media.documents/document/image%3A19
'content://com.android.providers.media.documents/document/image%3A19
If UriString.StartsWith("content://com.android.providers.media.documents") Then
Dim i As Int = UriString.IndexOf("%3A")
Dim id As String = UriString.SubString(i + 3)
' Uri1.Parse("content://media/images")
Uri1.Parse("content://media")
Cursor1 = cr.Query(Uri1, Proj, "_id = ?", Array As String(id), "")
Else
Uri1.Parse(UriString)
Cursor1 = cr.Query(Uri1, Proj, "", Null, "")
End If
Cursor1.Position = 0
Dim res As String
res = Cursor1.GetString("_data")
Cursor1.Close
Return res
End Sub