DELPHI XE5 Android - SAVE / LOAD file from SDCard

Viewed 10309

I am using Delphi XE5 for Android developing.

I like to save and load TStringList to text file on SDCard. When I save TStringList to file all is OK. After saving I can call LoadFromFile and file is loaded.

The problem is when I close the application and open it again. File does not exist? This is file location FileName := '/data/data/[com.MY.APP]/files/File.txt'

Under application user permissions = Write external stoage : True

Do I need to save the file to another folder?

Thx for help.

This in my code and settings.

procedure LOAD;
var
  TextFile: TStringList;
  FileName: string;
begin
     TextFile := TStringList.Create;
    try
      FileName := Format('%s/File.txt', [GetHomePath]);
      if FileExists(FileName) then
      begin
        TextFile.LoadFromFile(FileName);
        Memo1.Lines.Text := TextFile.Text
      end
      else
        ShowMessage('File not exists!');
    finally
      TextFile.Free;
    end;     

end;

procedure SAVE;
var
  TextFile: TStringList;
  FileName: string;
begin   
    TextFile := TStringList.Create;
    try
      FileName := Format('%s/File.txt', [GetHomePath]);
      TextFile.Text := Memo1.Lines.Text;
      TextFile.SaveToFile(FileName);
    finally
      TextFile.Free;
    end;     
end;

enter image description here

enter image description here

1 Answers
Related