Tree view listing of files 

104 views
Skip to first unread message

Nii Darko Darkoh

unread,
Feb 4, 2021, 8:36:28 PM2/4/21
to DroidScript
 Hi everyone, is there a code to list all files and folders in treeview fashion in DS?

Alan Hendry

unread,
Feb 5, 2021, 6:34:35 AM2/5/21
to DroidScript
Hi,
ListFolder can be used to list all the files and subfolders inside one folder.
If you want to list what is inside the subfolders you'd need to LIstFolder for every subfolder
(and then repeat for every subsubfolder, etc. commonly known as recursion).
You'd probably need to use arrays to keep track of the different levels of subfolder, subsubfolder, ...
(If you just want the user to pick a file or image then there's ChooseFile and ChooseImage but they only show one folder at a time). 
Regards, ah

Nii Darko Darkoh

unread,
Feb 5, 2021, 7:02:57 AM2/5/21
to DroidScript

Hi Alan, its been a while. I hope you are good.
So what I need is a display of all the folders.. Then when a folder is tapped
it will show its files and folders.
I dont want to use the choose file function because I don't want the user to know where 
the private folder is.
I hope there is a solution for this.
Thanks bro.

Alan Hendry

unread,
Feb 5, 2021, 8:42:06 AM2/5/21
to DroidScript
Hi,
You could try GetPrivateFolder and ChooseFile or ChooseImage
"Returns the path to a folder located in the apps private space which is normally not accessible by other apps or the user himself. "

Otherwise
I'd start by adding an empty List to the layout with a List OnTouch defined (more on that later).
Invoke a function (perhaps named F) passing it the path of your start folder
Function F will receive a path and do a ListFolder putting the files and subfolders in the List.
In the list OnTouch, if the user touches a file then do whatever your app needs to do.
If the user touches a subfolder then invoke F passing it the path of the subfolder).
If the user needs to go back then you need a button (disabled initially and when the user returns to the top, enabled for subfolders)
When the user touches the back button the button OnTouch should invoke F passing it the folder one level up.
Regards, ah
Reply all
Reply to author
Forward
0 new messages