I am trying to allow the user to send a file to his android device, download it into the internal "Download" directory and then import the file into the app.
I found the original 'Dialogs' library and had the problem as below and then found an updated 2017 'Dialogs2' library but it did not help.
I found in various forum entries the following hints and answers to problems:
1. From Erl to use : oFileDialog.FilePath=File.Combine(File.DirRootExternal,"Download") to properly access the "Download" file.
2. From another to test that the file is there. The log in the first portion of the sample code results in: "I am here" with no problem. So the path and the file name are correct.
3. From another to specify a color for the text in the dialog. Not sure why it doesn't default to black.
The dialog box that comes up shows no .txt files.
Here is the sample code. Something is missing.
I found the original 'Dialogs' library and had the problem as below and then found an updated 2017 'Dialogs2' library but it did not help.
I found in various forum entries the following hints and answers to problems:
1. From Erl to use : oFileDialog.FilePath=File.Combine(File.DirRootExternal,"Download") to properly access the "Download" file.
2. From another to test that the file is there. The log in the first portion of the sample code results in: "I am here" with no problem. So the path and the file name are correct.
3. From another to specify a color for the text in the dialog. Not sure why it doesn't default to black.
The dialog box that comes up shows no .txt files.
Here is the sample code. Something is missing.
B4X:
Sub btImport_Click
' sub to check the specs and then process the import
Dim oFileDialog As FileDialog
If File.Exists (File.Combine(File.DirRootExternal, "Download"), "LowKeyImportTest.txt") Then
Log("I am here") ' this log fires so the file is in the "Download" directory
Else
Log ("File does not exist in the Download directory")
End If
oFileDialog.TextColor=Main.txForeColor ' had to put this in to see anything
oFileDialog.FilePath=File.Combine(File.DirRootExternal,"Download")
oFileDialog.FileFilter = ".txt"
Log ("Import path:" & oFileDialog.FilePath)
If oFileDialog.Show ("Select a txt file to import","Select","","Cancel",Null)=-1 Then ' Dialog comes up as shown below in pic
Log ("Import File Name:" & oFileDialog.ChosenName)
Return
Else
Return
End If
End Sub