Android Question How To Access External Files?

Big Dave

Member
Licensed User
Longtime User
I need to read an excel spreadsheet and create a sql database. I have achieved it before but I am porting the app to a new tablet with a newer android version and cannot find where I can locate the external file or what code changes are needed. Listing the file locations gives me:
DirDefaultExternal = /storage/emulated/0/Android/data/b4a.konnqa3/files
DirInternal = /data/user/0/b4a.konnqa3/files
DirRootExternal = /storage/emulated/0
I cannot find any of these locations on the tablet? Are there restrictions on accessing external files with the newer versions of Android.

Thanks in advance for any suggestions.
 
I need to read an excel spreadsheet and create a sql database. I have achieved it before but I am porting the app to a new tablet with a newer android version and cannot find where I can locate the external file or what code changes are needed. Listing the file locations gives me:
DirDefaultExternal = /storage/emulated/0/Android/data/b4a.konnqa3/files
DirInternal = /data/user/0/b4a.konnqa3/files
DirRootExternal = /storage/emulated/0
I cannot find any of these locations on the tablet? Are there restrictions on accessing external files with the newer versions of Android.

Thanks in advance for any suggestions.
It's not possible anymore since Android 11.
You need to connect your device with the USB cable to the computer and then you will be able to open a device as a network drive.
 
Upvote 0
Upvote 0
Still trying to access external files. Trying to compile the ManageExternalStorage example but it is complaining about an unknown member ShowAsync as per the line below.
Dim fda As Object = fd.ShowAsync("B4A File Dialog", "OK", "Cancel", "", Bmp, False)
I believe this is something to do with Dialog2 library which I cannot find? Can someone point me in the right direction please.

Thanks.
 
Upvote 0
Still trying to access external files. Trying to compile the ManageExternalStorage example but it is complaining about an unknown member ShowAsync as per the line below.
Dim fda As Object = fd.ShowAsync("B4A File Dialog", "OK", "Cancel", "", Bmp, False)
I believe this is something to do with Dialog2 library which I cannot find? Can someone point me in the right direction please.

Thanks.
Are you using this example? Is this library Dialog2 you are looking for?
 
Upvote 0
Are you using this example? Is this library Dialog2 you are looking for?
Hi

Finally managed to get it to work and list the folders which I can dig down into. However it is not showing me any actual files to select, just folders are listed. Is there anything extra I need to do. I ran the ManageExternalStorage and that works perfectly. If it helps my code is:

Dim fdFile As FileDialog
fdFile.FilePath = File.DirRootExternal
fdFile.FileFilter = ".xls"
Dim fda As Object
fda = fdFile.ShowAsync("Select spreadsheet file to load", "Load", "Cancel", "", Null, False)
Wait For (fda) dialog_result(result As Int)

Thanks for the help to date.
 
Upvote 0
Hi

Finally managed to get it to work and list the folders which I can dig down into. However it is not showing me any actual files to select, just folders are listed. Is there anything extra I need to do. I ran the ManageExternalStorage and that works perfectly. If it helps my code is:

Dim fdFile As FileDialog
fdFile.FilePath = File.DirRootExternal
fdFile.FileFilter = ".xls"
Dim fda As Object
fda = fdFile.ShowAsync("Select spreadsheet file to load", "Load", "Cancel", "", Null, False)
Wait For (fda) dialog_result(result As Int)

Thanks for the help to date.
Instead of File.DirExternal use this

B4X: Copy
Dim rp As RuntimePermissions
Dim subFolderName,FolderName as String


FolderName=rp.GetSafeDirDefaultExternal(subFolderName)

Also use this https://www.b4x.com/android/forum/threads/open-external-files-with-your-app.50525/#content
 
Upvote 0
Back
Top