In my code I create a .TXT file and store it in the shared folder “Download” like this:
procedure TF_start.Button2Click(Sender: TObject);
path_file output_text: string;
path_file := TPath.Combine(System.IOUtils.TPath.GetSharedDownloadsPath, ‘Folder_app’);
output_text := ‘test’;
if not TDirectory.Exists(path_file) then
TFile.WriteAllText(TPath.Combine(path_file, Nome_Arquivo), Arquivo_saida);
ShowMessage(‘An error occurred while saving the file.’);
The file is perfectly created, but Android itself has a problem indexing the files so they can be read through Windows Explorer, so you have to rescan the folder that the file was created for so that it can be visible.
There are even some apps on PlayStore that rescan the entire sdcard, but asking my client to install a secondary file to use my app is not a good choice …
I found a code that theoretically performs this rescan on a specific folder, but it doesn’t work. There are no errors, but the folder and the file continue is not visible in Windows Explorer …
The code is this:
procedure TF_corrida.BTNfinalize_appClick(Sender: TObject);
while not JMediaScannerCon.isConnected do begin
if (c>20) then break;
if (JMediaScannerCon.isConnected) then begin
Does anyone know why this code is not working? I even came to see that it didn’t work in Delphi Tokyo, but I’m using Delphi Rio.
And yes, I correctly stated the READ and WRITE storage permissions in my code. The file is created correctly, just not visible.