0
votes

I use Delphi XE6 FDConnection's "Connection editor" to select my database as e.g. E:\OpiBord\myDB.s3db and it runs without problem on Windows. But this is a multi-platform application. So how do I specify the database location so that it is valid for e.g. Android as well?

I looked at http://docwiki.embarcadero.com/RADStudio/XE5/en/Creating_an_Android_App and found the function to locate a file on Android ... TPath.Combine(TPath.GetDocumentsPath, 'filename')

Do I have to change the file path dynamically for Android, iOS?

1

1 Answers

0
votes

Try this use this code, you can put it at BeforeConnect event:

//sqlConn is a TFDConnection
{$IF DEFINED(iOS) or DEFINED(ANDROID)}
    sqlConn.Params.Values['Database'] := TPath.Combine(TPath.GetDocumentsPath, 'myDB.s3db');
{$ELSE}
    sqlConn.Params.Values['Database'] := 'E:\OpiBord\myDB.s3db';
{$ENDIF}