Android Question Where is the externalstorage library?

evan_2026

Member
my log: Unknown type: externalstorage
Are you missing a library reference?

I wonder, where is the library?
It not in the libraries manager list.
What shall do?please
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
Upvote 0

evan_2026

Member

First search result: https://www.b4x.com/android/forum/pages/results/?query=externalstorage
Yeah!
I take the ExternalStorage.b4xlib to x4a's Libraries. Now, it appeared in the sdkmanager list!
Thanks your information.
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Upvote 0

evan_2026

Member
execuse me
" Storage.SelectDir(True)
Wait For Storage_ExternalFolderAvailable"
After executing the above statement,How do I get the complete folder?
example:
dim str1 as string
str1 =Storage.SelectDir(True)
Wait For Storage_ExternalFolderAvailable
log(str1)
the result is no output
 
Upvote 0

MicroDrie

Well-Known Member
Licensed User
Longtime User
Goto Duckduckgo https://duckduckgo.com/ and type type:
How to get all files in the selected directory with the B4A external storage library
Click on Duck.ai
And the answer is:
n B4A, once the user has selected a directory with the ExternalStorage library, you list its contents the same way you’d list a normal folder with File.ListFiles, using the path (or folder handle) returned by ExternalStorage.

Example (non-recursive):

basic


B4X:
'Assume SelectedDirPath is the directory path returned by ExternalStorage
'e.g. "/storage/emulated/0/Download/MyFolder"

Dim SelectedDirPath As String = ExternalStorage1.SelectedDirPath  'adjust to your actual property/method

Dim items() As String = File.ListFiles(SelectedDirPath, "*")

For i = 0 To items.Length - 1
    Log(items(i))
Next

'Assume SelectedDirPath is the directory path returned by ExternalStorage'e.g. "/storage/emulated/0/Download/MyFolder"

B4X:
Sub ListDirRecursive(BasePath As String, Prefix As String)
    Dim items() As String = File.ListFiles(BasePath, "*")

    For i = 0 To items.Length - 1
        Dim name As String = items(i)
        Dim full As String = File.Combine(BasePath, name)

        If File.IsDirectory(full) Then
            ListDirRecursive(full, Prefix & name & "/")
        Else
            Log(Prefix & name)  'file found
        End If
    Next
End Sub

Sub AppStart
    Dim SelectedDirPath As String = ExternalStorage1.SelectedDirPath  'adjust
    ListDirRecursive(SelectedDirPath, "")
End Sub

If you paste the exact ExternalStorage code you’re using to get the selected directory (the line where you receive/store the selection), I’ll adjust the snippet to match the exact property/method names your version of the library uses.
You can test the suggestion, and if there are errors, press Control-R, go to Google, and paste the JSON file into the input field. After submitting the query, Google will analyze the error and provide suggestions as to what is wrong.

Good luck
 
Upvote 0

evan_2026

Member
Goto Duckduckgo https://duckduckgo.com/ and type type:

Click on Duck.ai
And the answer is:

You can test the suggestion, and if there are errors, press Control-R, go to Google, and paste the JSON file into the input field. After submitting the query, Google will analyze the error and provide suggestions as to what is wrong.

Good luck
‌I cannot access the website above
and the code you pasted also won't run.
But thank you on the same.
I've found a post of DonManfred, there is a FilePicke library.
Use it to select files or folders and return a full directory path.
I am learning how to use it...
Have a nice day!
 
Upvote 0
Top