1

When I run Android app it's working fine. Problem when I change some data and click button 'Save Changes'. Then again run App it's showing old data.

I need My App load me saved one.

I'm using Delphi Xe8->Multi-Device App. Using

For Android, I set the Remote Path to assets\internal -->.\assets\internal\ Deployment

Save Changes button Code:

procedure TForm1.Button1Click(Sender: TObject);
begin
CDS.SaveToFile(TPath.GetDocumentsPath + PathDelim + 'users.cds');
end;

OnCreate Code:

procedure TForm1.FormCreate(Sender: TObject);
begin
CDS.LoadFromFile(TPath.GetDocumentsPath + PathDelim + 'users.cds'); //Embarcadero\Studio\Projects\example\Client\Android\Debug\Client\assets\internal
end;
Alex Kirov
  • 217
  • 4
  • 16
  • Have you tried displaying on your form (or in the debugger) the value of the expression `TPath.GetDocumentsPath + PathDelim + 'users.cds'` and confirmed that it is the same in `FormCreate` and `Button1Click`? – MartynA Feb 16 '17 at 10:27
  • yes, they're the same[FormCreate and ButtonClick]. – Alex Kirov Feb 16 '17 at 10:48
  • Well, the CDS's SaveToFile and LoadFromFile normally work without any problem, but I've only ever used them under Windows. Maybe your problem is Android-specific, to do with user-permissions or something. Can you save a TMemo's contents to the same folder and reload it and save changes to it, etc? – MartynA Feb 16 '17 at 11:38
  • Btw, you might take a look at this q: http://stackoverflow.com/questions/18857936/how-to-save-a-file-on-android-firemonkey and in particular, Leslie Kaye's answer. – MartynA Feb 16 '17 at 11:52
  • I put On Memo1.lines.add(TPath.Combine(TPath.GetDocumentsPath, 'users.cds')). I got this path: /data/data/com.embarcadero.Client/files/users.cds – Alex Kirov Feb 16 '17 at 15:08
  • Sorry, that's not what I meant. Can you save and reload the contents of a TMemo to the same folder? – MartynA Feb 16 '17 at 15:17
  • You have not shown how you're changing the data in the CDS. – Ken White Feb 16 '17 at 19:12
  • i'm not sure does it matter but the `Remote path` is usually `assets\internal\ ` – Henrikki Feb 17 '17 at 07:31
  • Dear @ MartynA . I need your help : http://stackoverflow.com/questions/42431336/delphi-how-to-call-actionlist-on-button?noredirect=1#comment72008357_42431336 – Alex Kirov Feb 24 '17 at 05:59

1 Answers1

3
AppPath := TPath.GetHomePath;
FileName := TPath.Combine(AppPath, 'users.cds');
Alex Kirov
  • 217
  • 4
  • 16