In 2 projects, I use the same code.
In one of them the file browser dialog appears with white letters on a black background - great.
In the other, using the same code, its white -ish on a white background.. the folder and file names are almost unreadable.
ANy idea why the difference and how to address it?
B4X:
Try
Dim fd As FileDialog
fd.FilePath = File.DirRootExternal
Dim sf As Object = fd.ShowAsync("Select file", "Open", "Cancel", "", Null, False)
Wait For (sf) Dialog_Result(Result As Int)
If Result = DialogResponse.POSITIVE Then
'Do stuff with the file here
End If
Catch
Log ("Error opening file chooser")
End Try
FileDialog was more relevant in the past. Google is hiding the file system from the user and with each version it becomes more difficult to access it directly. You more or less need to forget from FileDialog and File.DirRootExternal.
You should instead use ContentChooser with FileProvider.
Sub Class_Globals
Private Root As B4XView
Private xui As XUI
Private CC As ContentChooser
End Sub
Public Sub Initialize
CC.Initialize("CC")
End Sub
Private Sub B4XPage_Created (Root1 As B4XView)
Root = Root1
Root.LoadLayout("MainPage")
End Sub
Sub Button1_Click
CC.Show("*/*", "Choose file")
Wait For CC_Result (Success As Boolean, Dir As String, FileName As String)
If Success Then
End If
End Sub
Looking at ContentChooser, it appears to suggest that 'some other application needs to be able to provide the content'
I assume that is file explorer? What if there isnt a file explorer?
The docs say: Mime - The content MIME type. Title - The title of the chooser dialog (when there is more than one application).
Examples: CC.Show("image/*", "Choose image")
CC.Show("audio/*", "Choose audio file")
My files don't have a mime type .. how do I handle that?
eg I have a file format that has an extension of (say) TPL .. no other app handles such files...
The content chooser gives a nicer looking dialog.
Took a while to change the settings so that I could see my files in a 'Downloads' folder.
But there is a big difference in the way the directory and file names are returned.
File Dialog gives me
Dir = /storage/emulated/0/download
and
filename = Myfile.OXS
Content Chooser gives me
Dir = ContentDir
Filename = content//com.android.externalstorage.documents/document/primary%3ADownload%2FMyfile.OXS
While I can use the values from file dialog to get my file, I cant work out how to use the values from Content Chooser.
Is the presence of the %3A and %2F causing an issue?
File.exists(Dir,Filename) returns false with Content Chooser, and true for the File Dialog
I should add that this target file is an XML file.
What I want to do next is parse it.