Android Question How to get file location?

Nokia

Active Member
Licensed User
Longtime User
I am trying to convert my b4j app to b4a..

I have seen a few samples but not enough to make since.

I'm trying to get the file path (uri) from a file I downloaded on to my Galaxy S9 phone (in download folder) to my app so my app can import the file.

Any good examples of this?

thanks..
 

Nokia

Active Member
Licensed User
Longtime User
If I use ConentShooser to get the uri and I put it in file.exists(dir,filename) it comes back false...
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Where is the relevant code used?
 
Upvote 0

Nokia

Active Member
Licensed User
Longtime User
ContentChooser returns a URI that points to a resource. The resource exists however it is not a real file so File.Exists returns False.

How do I get the location of the file so that file.exists works?
 
Upvote 0

Nokia

Active Member
Licensed User
Longtime User
Please upload a small project which shows the issue.
Hard to help without seeing what you have done and how.

this was the code I was using..

B4X:
    cc.Initialize("CC")
    cc.Show("*/*", "Choose File")
    Wait For CC_Result (Success As Boolean, Dir As String, FileName As String)
    If Success Then
        Log(FileName)
        Log(Dir)
        
        txtLDBrowse.Text = FileName
        
        If File.Exists(Dir, FileName) Then
            Log("file exitst")
        Else
            Log("Can't find it")
        End If
    End If
 
Upvote 0

Nokia

Active Member
Licensed User
Longtime User
Remove this check. It is not needed.
The resource is there. You cannot get its location because it might not be a file and even if it is a file you are not accessing it directly.

thanks Erel..

that worked.. will have to make some changes to the code but it worked...
something I will have to get use to...
 
Upvote 0
Top