GetFiles doesn't

Anyone had any trouble with GetFiles (System.IOUtils.TDirectory.GetFiles(oduCurrentDirectory, ‘.’, nil)
not returning all of the files in an android directory?
Again, this code worked fine up to Delphi 10.4, and does strange things (returning from zero to about half the actual number of files) in 11.1.
I have tried FindFirst/FindNext/FindClose, but the first FindFirst always returns -1.
Yes, the permission for secure file sharing has been ticked, and read and write permissions gained.

What is oduCurrentDirectory?

G;day, Eivind.
No problems making directories; no problems making the files. Just can’t find them to read afterwards, though they show up with ES File Explorer, MyFiles (the samsung app) and on connecting the phone to a computer.
I realise that one day I am going to have to learn how to drive that confusion that Android has immersed its file system into, but I do not know where to find information on how to do this in Delphi, or examples. The Delphi help text is not helpful, and the net is full of Java examples! Can you point me to this information please?
The next question is how to use MANAGE_EXTERNAL_STORAGE. If I just include it in a GetPermissions subroutine in the programme, it gets denied. The net talks about “intent”, whatever that means, and maybe something in the manifest.
All ideas will be read with interest and gratitude, if it means I can get the next bit of this beast working properly (worked great guns in android 7!).

Permissions were significantly tightened and chaged on Android 11 so if you are having issues you are not alone. However my requirement was simpler
This link helped me but I was not trying to do file manager type things just opening and saving a clientdatset
The phone I’m using is a smasung A71 5g with android 11 (upgraded from 10)
However I’m placing the data file in the documents folder which is either shareddocuments or documents depending on if they downloaded the app to phone or external memory card
In the main uses clause I have the following items specific to Android

// for Android compile uncomment these below
// Androidapi.Jni.Os, Androidapi.Helpers,
// Permissions ticked in the project options,
// In the form create event :-
    FPermissionWrite := JStringToString(TJManifest_permission.JavaClass.WRITE_EXTERNAL_STORAGE); 
    FPermissionRead := JStringToString(TJManifest_permission.JavaClass.READ_EXTERNAL_STORAGE);
    PermissionsService.RequestPermissions([FPermissionWrite, FPermissionRead], nil);
    sdataPath := System.IOUtils.TPath.Combine(System.IOUtils.tpath.getdocumentspath,[filename.cds]);

If that returns no file then the getshreddocuments path rout
Not sure if this helps :slight_smile:

oops here is the link

Thanks. I find the emozgun stuff impenetrable: it has very little information about what each bit is doing, variables/classes/functions without “uses” file they require (and involve many hours of searching with windows search and grep) to try to locate (and often fail), and some rather patchy English which does not help.

All I want to to is read and write files with routines, and to be able to read the directory where I have written the files, with GetDirectories / GetFiles.

It talks about system pickers and intents (neither of which I have ever had to use, and do not know where to find information on them - except in ruddy Java!), examples of bitmaps and pdf files, and nothing about really basic reading and writing chunks of bytes!

Is to do this now deprecated? Reading and writing with tFile still seem to work, but the GetFiles seems to have become rather worse than useless. Interesting that ES File Explorer has no trouble finding the files!

Looking at the emozgun stuff for accessing a directory (the one I want is the documents/Pete subdirectory, which I had no trouble creating the directory, and writing into it):

Grant access to a directory’s contents

procedure openDirectory(uriToLoad : JNet_Uri); (* DizinAc *) {what is a DizinAc?}
{Needs a Uri - is that just a JString(filename), or something more ferocious>}
// Choose a directory using the system’s file picker. {Where and what is that?}
Intent : JIntent; {Would be nice to know which “uses” file to include}
Intent := TJIntent.Create;

// Optionally, specify a URI for the directory that should be opened in
// the system file picker when it loads.
Intent.putExtra(TJDocumentsContract.JavaClass.EXTRA_INITIAL_URI, JParcelable(uriToLoad));

Mainactivity.startActivityForResult(Intent, Open_Doc_Tree); {Open_Doc_Tree appears to be undefined anywhere}