Skip to content Skip to sidebar Skip to footer

How To Show The Availble Files In Android Memory With Firemonkey

In Delphi for Windows one has the TOpenDialog and the commands such as FindFirst. In Firemonky/Android there is no TOpenDialog, but according to many forumsFindFirst` should exist.

Solution 1:

The functionality available in IOUtils is all you need. This code (tested on my Nexus 7) populates a TMemo with the files in your folder (if there are any):

uses
  IOUtils;

procedure THeaderFooterForm.SpeedButton1Click(Sender: TObject);
var
  DirList: TStringDynArray;
  DirPath: string;
  s: string;
begin
  DirPath := TPath.Combine(TPath.GetDocumentsPath, 'assets');
  DirPath := TPath.Combine(DirPath, 'internal');

  // Display where we're looking for the files
  Memo1.Lines.Add('Searching ' + DirPath);

  if TDirectory.Exists(DirPath, True) then
  begin
    // Get all files. Non-Windows systems don't typically care about
    // extensions, so we just use a single '*' as a mask.
    DirList := TDirectory.GetFiles(DirPath, '*');

    // If none found, show that in memo
    if Length(DirList) = 0 then
      Memo1.Lines.Add('No files found in ' + DirPath)
    else // Files found. List them.
    begin 
      for s in DirList do
        Memo1.Lines.Add(s);
    end;
  end
  else
    Memo1.Lines.Add('Directory ' + DirPath + ' does not exist.');
end;

Post a Comment for "How To Show The Availble Files In Android Memory With Firemonkey"