Hey,
if i share a image with my app from WhatsApp, then the uri looks so:
Normally I get all paths with this code:
but there this error occurs:
What do I have to do to get the right path?
if i share a image with my app from WhatsApp, then the uri looks so:
B4X:
content://com.whatsapp.provider.media/item/705a29e3-195e-47ad-97de-adebcedb83e0
B4X:
Public 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("")
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/external/images/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
B4X:
java.lang.IllegalArgumentException: column '_data' does not exist. Available columns: []
What do I have to do to get the right path?