How to Develop Android Database Applications in RAD Studio XE5

October 8th, 2013

Not so long ago, in RAD Studio XE5 there was introduced support for Android application development. On the Internet there can be found a lot of information about Android application development in Delphi XE5, but when it comes to development of database applications, it becomes much more difficult. The point is that the components and drivers included in the RAD Studio XE5 distribution (for example, FireDAC and dbExpress drivers) have severe limitations: on Android and iOS platforms, they support just 2 databases — SQLite and InterBase. And what to do when you develop a serious business-application, that requires remote connection to Oracle, MySQL or PostgreSQL from Android? We have come across such questions on various forums dedicated to database application development for Android and decided to reveal the topic as detailed as possible.


Let’s start with description of the components we will use:

  • UniDAC – it is universal data access components that allow to connect to SQLite, Oracle, MySQL, PostgreSQL, and InterBase from Android (you can use UniDAC for connection from Windows to almost all the known databases, but this is beyond the scope of this blog).

If you want to work not with all those databases, but with a particular one, you can use more specific components:

  • LiteDAC – SQLite Data Access Components
  • ODAC – Oracle Data Access Components
  • MyDAC – MySQL Data Access Components
  • PgDAC – PostgreSQL Data Access Components
  • IBDAC – InterBase Data Access Components

All these components also support Android as a target platform in RAD Studio XE5.

Connection to database

Work with databases on Android in general is no different from the one on Windows, but there are some nuances when setting connection and deploying files to a mobile device, if you work with a local DB. We will consider here how to establish connection to each supported database.


If you not deploy the database file to a mobile device, you should set:

In this case, on the first application launch, a database file will be created automatically.

LiteDAC sample

UniDAC sample


It is impossible to install Oracle client to a mobile device, because Oracle client for Android simply doesn’t exist. Therefore the only way to establish connection to Oracle from a mobile device is to connect directly via TCP/IP. For this, the Direct option should be set to True:

In addition, the server name must be generated correctly, since, if we have no client, we have no tnsnames.ora file with the server list as well. Therefore, to establish connection from Android, we need to know the server Host and Port, as well as its SID or Service Name.

To connect via the SID, the server should be set in the following way:

or a simplified way:

To connect via the Service Name – as follows:

In other words, the ‘sid=’ prefix of the third parameter indicates that connection is established via the SID, and the ‘sn=’ prefix indicates that connection is established via the Service Name. If no prefix is specified, then, by default, it is considered, that we want to establish connection via the SID.

The majority of Oracle servers have the same SID and Service Name, so you, most likely, won’t have to go into such nuances, since you can learn more about this in the Oracle documentation.

ODAC sample

UniDAC sample


MySQL client software for Android also doesn’t exist, therefore connection to MySQL server will also be established directly via TCP/IP. For this, let’s set the corresponding option:

MyDAC sample

UniDAC sample


With PostgreSQL, everything is more simple. Since PgDAC and UniDAC only allow establish direct connection via TCP/IP, it is enough for us to specify the Server and Port and perform Connect.

PgDAC sample

UniDAC sample


Using InterBase ToGo, you can connect to both local or remote DB.

To connect to a local db, just the path to the local db on the device should be set:

If you need to establish connection to a remote server, you should specify not only the database, but the server as well:

Please note that the IncludeTrailingPathDelimiter(TPath.GetDocumentsPath) prefix should be specified when connecting to a local DB, and it is not needed for connection to a remote database.

IBDAC local database sample

IBDAC remote database sample

UniDAC local database sample

UniDAC remote database sample


Deployment to mobile device

In order for our application to be able to work with local SQLite and InterBase ToGo databases, we should make sure these databases are deployed to an Android device. Nothing difficult at this, since the deployment process is similar in both Delphi XE4 and Delphi XE5. First we should call the Project->Deployment menu:

After this add our databases for SQLite and InterBase to the list of files, that must be deployed to an Android device together with your application:

Please note that the deployment path is different for Android and iOS. If you want to deploy your application to both platforms, then make sure the deployment paths are specified correctly for both of them.

NOTE: Dont forget to change the Remote Path default value . with one of the described above.

Deployment Path Destination on Device
TPath.GetDocumentsPath .\assets\internal /data/data/com.embarcadero.MyProjects/files
TPath.GetSharedDocumentsPath .\assets /mnt/sdcard/Android/data/com.embarcadero.MyProjects/files


We won’t focus on the debug process in this article, since it was described in details in the previous article: Remote Debug of Android Applications in RAD Studio XE5 via Wi-Fi


For the time being, with the RAD Studio XE5 release, Devart Data Access Components allow to connect to SQLite, Oracle, MySQL, PostgreSQL and InterBase from both mobile platforms: Android and iOS. But we are not going to stop. Many users ask us to support connection to SQL Server from Android and iOS – and we will make every effort to give them such a capability.


We are glad to inform, that we have supported connection to SQL Server and SQL Azure from iOS and Android.

12 Responses to “How to Develop Android Database Applications in RAD Studio XE5”

  1. Компоненты доступа к данным от DevArt - новые возможности для разработки под Android | Delphi 2010 ru Says:

    […] в блоге компании был опубликован пост-инструкция “How to Develop Android Database Applications in RAD Studio XE5“, из которого явственно следует, с помощью […]

  2. Prashant Bhosale Says:

    nice article

  3. Marco Antonio Santin Torres Says:

    And you can not connect to a SQL Server database?

  4. DAC Team Says:

    We are now working at this.

  5. D.Wy Says:

    interesting ! , how about firebird ?

  6. DAC Team Says:

    As soon as a Firebird client library for Android is released, we will immediately engage in implementing support for it.

  7. Ramil Rustamov Says:

    Are you serious? Is it impossible to connect to MSSQL Server?
    The only reason that I’ve downloaded your components was to make easily and possible to connect to MSSQL Server otherwise your components are useless!

  8. DAC Team Says:

    Currently, SDAC and UniDAC don’t support connection to MS SQL Server. This information can be seen on the compatibility pages of these products: and

    We plan to add a capability to connect to MS SQL Server on mobile platforms by the end of the year. Follow the news on our website.

  9. untung Says:

    with datasnap + unidac, you can communication with ms sql server.

    unidac make it simple.

  10. mehmet akif kabakçı Says:

    where will this code be pasted?

    Connection: TUniConnection;
    Connection := TUniConnection.Create(nil);
    Connection.ProviderName := ‘SQLite’;
    Connection.SpecificOptions.Values[‘ForceCreateDatabase’] := ‘True’;
    Connection.Database := IncludeTrailingPathDelimiter(TPath.GetDocumentsPath) + ‘db.sqlite3’;

    and will be entered any “uses”?

    i still have trouble errors on my device when i tried. please send an example project thank you.

  11. DAC Team Says:

    Please specify the errors you are getting on your device or provide screenshots with them. In order to be able to help you resolve the issues.

  12. Kelly Bamson Says:

    Nice Post.Thank you for Sharing with us.

Leave a Comment