dmitrybv 3 Posted April 6 Good day. Embarcadero® RAD Studio 12 Version 29.0.55362.2017 Android 13, Samsung S20. I have files taken by the camera in the folder '/storage/emulated/0/DCIM/Camera' on my phone. How to set up the Android application correctly so that I can get a list of these files? When creating an Fmx application by default, the command TDirectory.GetFiles('/storage/emulated/0/DCIM/Camera') returns an empty list. Share this post Link to post
Remy Lebeau 1572 Posted April 7 (edited) Have you tried TPath.GetCameraPath() yet? Does your app have permission to access the camera files? Edited April 7 by Remy Lebeau Share this post Link to post
dmitrybv 3 Posted April 7 TPath.GetCameraPath() returns the following value - '/storage/emulated/0/Android/data/com.embarcadero.EhLib_Fmx_MainDemo/files/DCIM'. When viewing from the program via TDirectory.GetFile, this folder does not contain files. When viewing from the phone, I cannot access the folder ‘/storage/emulated/0/Android/data/com.embarcadero.EhLib_Fmx_MainDemo’ at all. Share this post Link to post
dmitrybv 3 Posted April 7 Is there a Demo project in RAD Studio Samples or on github.com that demonstrates the ability to view photos in the app taken via the camera? Perhaps the TDirectory.GetFile method on Android does not work correctly or the app should request some rights via User Persmissions. Share this post Link to post
ToddFrankson 8 Posted April 7 12 hours ago, dmitrybv said: TPath.GetCameraPath() returns the following value - '/storage/emulated/0/Android/data/com.embarcadero.EhLib_Fmx_MainDemo/files/DCIM'. When viewing from the program via TDirectory.GetFile, this folder does not contain files. When viewing from the phone, I cannot access the folder ‘/storage/emulated/0/Android/data/com.embarcadero.EhLib_Fmx_MainDemo’ at all. I'm no expert but that looks like you have not gotten permissions. Share this post Link to post
Dave Nottage 605 Posted April 7 On 4/7/2025 at 6:48 AM, dmitrybv said: How to set up the Android application correctly so that I can get a list of these files? I've created a demo in my HowTo repository. It also demos a way of accessing the contents of the files, since you cannot use the "traditional" methods of accessing the files in Delphi. 1 Share this post Link to post
dmitrybv 3 Posted April 7 Hello, Dave Thanks for the demo project. Is there a more universal way to view the list of files in Android folders? Regarding the TDirectory.GetDirectories(), TDirectory.GetFiles() methods, I noticed that the TDirectory.GetDirectories('/storage/emulated/0/') method returns a list of folders similar to what is visible in the Files by Google program. Files by Google displays files in folders such as: '/storage/emulated/0/DCIM/Camera' '/storage/emulated/0/DCIM/Screenshots' '/storage/emulated/0/Documents' '/storage/emulated/0/Download' but the TDirectory.GetFiles() method does not return any files when specifying any path. What method should be used in Android to get a list of files in a folder? Share this post Link to post
Dave Nottage 605 Posted April 7 51 minutes ago, dmitrybv said: What method should be used in Android to get a list of files in a folder? It depends on the folder. If it's private to the app (e.g. via TPath.GetDocumentsPath) then TDirectory.GetFiles will work. If the folder is shared (as are those that you listed), then a method similar to what is in the demo could be used, i.e. via ContentResolver. Share this post Link to post
Dave Nottage 605 Posted April 8 (edited) 7 hours ago, Dave Nottage said: If the folder is shared (as are those that you listed), then a method similar to what is in the demo could be used, i.e. via ContentResolver. Actually, there is more to this. If you need access to files other than audio, images and video that are not created by your app, you would need to use the relevant action(s), as described here. This kind of thing is implemented in the FilesSelector feature in Kastri. Edited April 8 by Dave Nottage 1 Share this post Link to post