How to save a file on Android? (Firemonkey) How to save a file on Android? (Firemonkey) android android

How to save a file on Android? (Firemonkey)


According to the document Creating an Android App, get the documents path like this:

System.IOUtils.TPath.GetDocumentsPath + System.SysUtils.PathDelim + 'myfile';


Instead of using System.SysUtils.PathDelim, you may use

System.IOUtils.TPath.Combine(System.IOUtils.tpath.getdocumentspath,'test.txt');

Combine chooses between the windows \ and the Linux /

System.IOUtils must be used in this line instead of setup in the uses clause because there are probably more Tpath initials.


GetHomePath, return a string with the path.-> 'data/data//files'

You can to use:

Memo.Lines.SaveToFile(format('%s/test.txt', [GetHomePath]));

Or this form

Memo.Lines.SaveToFile(GetHomePath + '/test.txt');