How to save a file on Android? (Firemonkey)

Reinier picture Reinier · Sep 17, 2013 · Viewed 36.8k times · Source

How can I save a file locally on an Android device, using Delphi (XE5, Firemonkey)?

Something as simple as

  Memo.Lines.SaveToFile('test.txt')

does not seem to work. It results in the following error message:

"Cannot create file "/test.txt". Not a directory."

Answer

Marcus Adams picture Marcus Adams · Sep 17, 2013

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

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