TXT file on android

Asked

Viewed 715 times

0

How do I write a TXT file to android using Delphi 10 Seatle? I’ve tried that way and only from mistake;

  try
    file1 := TIniFile.Create(System.IOUtils.TPath.GetDownloadsPath+PathDelim+'postogestorcoletor.ini');
    file1.WriteString('postogestorcoletor','testeteste', 'asasasasasas');
    file1.Free;
  finally
    ShowMessage('Erro ao criar arquivo');
  end;
  • Do the operation without Try (error handling) to know which exception is occurring. By the way, on which line is the error occurring?

  • Searching in Sopt, I found the answer: https://answall.com/a/82504/49822

  • I took the Try block and shows no error, simply does not create the file.

1 answer

1


I don’t know why you create the file on Android, I usually create the file in folder . ini and when I do the Deploy I’ll send the file along.

I hope I’ve helped.

uses
   System.IOUtils   

{$IF DEFINED (ANDROID)}
file1 := TIniFile.Create(TPath.Combine(TPath.GetDocumentsPath,'postogestorcoletor.ini');
try
  file1.WriteString('postogestorcoletor','testeteste', 'asasasasasas');
finally
  FreeAndNil(file1);
end;
{$ENDIF}
  • It even creates the file, but creates it in the android/ data/com.scanner folder. The ideal would be at the root.

  • @Alexandrevieira try to switch to Tpath.Getdownloadspath

  • I’ve done it, but now I’ve changed the form of persistence to Sqlite database, ta giving some errors, depending open another question hehehehe

Browser other questions tagged

You are not signed in. Login or sign up in order to post.