How to create file name list from a folder/directory

620 views
Skip to first unread message

Sfazist

unread,
Apr 10, 2015, 1:42:38 AM4/10/15
to mitappinv...@googlegroups.com
Dear Fellows,

I am working on an image app. I am using TinyDB to store image location.I have implemented a delete function in the app as well which deletes file from its location and also clearTag from TiyDB. My problem is, when user deletes images from image location (folder/directory) without using application image delete function (e.g. by using any file manager etc.) TinyDB sill contains its Tag alive.  

One solution could be a list of existing files from image location (folder/directory) and this could help to find images which is present in TinyDB tags but it has been deleted from image location (folder/directory). So, how to create file name list from a folder/directory?:)

Stephen Zipprich

unread,
Apr 10, 2015, 7:33:12 AM4/10/15
to mitappinv...@googlegroups.com
Why not have a check when your application loads if the file still exists, and if not, delete the tag from TinyDB?

Sfazist

unread,
Apr 10, 2015, 8:13:40 AM4/10/15
to mitappinv...@googlegroups.com
Thanks Stephen,

you are right, it should be checked during initialization time of application. Let me explain a bit more

  1. Its not a single file. it could be more number of files deleted by user without using app delete function.
  2. Application has a list of all DBTags. i have to compare this list with existing files in a folder/directory.
Any way, how can i find that a file eg. test.png  exist in /imagefolder/ or not. 

Taifun

unread,
Apr 10, 2015, 10:10:54 AM4/10/15
to mitappinv...@googlegroups.com
So, how to create file name list from a folder/directory?
App Inventor does not offer a feature to get a list of filenames of a directory

a workaround is to call a terminal emulator app using the activity starter and store the result in a file, then read the file using the file component
the statement to execute could be something like this (assuming you want to list all files in directory /mnt/sdcard/Music including all subdirectories)

ls -R /mnt/sdcard/Music > /mnt/sdcard/myResult.txt && exit

Taifun

Trying to push the limits of App Inventor! Snippets and Tutorials from Pura Vida Apps by Taifun.         

Reply all
Reply to author
Forward
0 new messages