Android Question Get file info from ContentChooser works only in debug mode.

rogeriosca

Member
Licensed User
Longtime User
Hi all!

I can´t understand why this code works only in debug mode, please anybody can help me?

B4X:
Sub GetFileInfo(aURI As String) As Map
    
    Dim oCur As Cursor
    Dim oURI As Uri
    Dim oCR As ContentResolver
    Dim mRes As Map
    Dim arrInfo() As String = Array As String("_display_name", "mime_type")
                
    oURI.Parse(aURI)
    
    oCR.Initialize("")   
    oCur= oCR.Query(oURI, arrInfo, Null, Null, Null)
    
    oCur.Position = 0
    
    mRes.Initialize
    
    Try
        mRes.put("display_name", oCur.GetString("_display_name"))
    Catch
        mRes.put("display_name", "")
    End Try
    
    Try
        mRes.put("mime_type",oCur.GetString("mime_type"))
    Catch
        mRes.put("mime_type","")
    End Try
    
    Log(mRes)
     
    oCur.Close
    Return mRes
 
        
End Sub

Thank you!
 

DonManfred

Expert
Licensed User
Longtime User
Post the full error you got! We can not gues it
Remove the try catch to get the error

Best is to upload a small project showing the problem.

Note that is better to use QueryAsync. It can take some time. Better use the async-version

you need to wait for the QueryCompleted-Event bevor you can access its Cursor.
QueryCompleted (Success As Boolean, Crsr As Cursor)
 
Last edited:
Upvote 0

rogeriosca

Member
Licensed User
Longtime User
Thanks @DonManfred for the tips!

I solved this changing Selection and SortOrder:

From:
oCur= oCR.Query(oURI, arrInfo, Null, Null, Null)

To:
oCur= oCR.Query(oURI, arrInfo, "1=1", Null, "")
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…