Is it possible to create an Android or IOS RemoteDB server?


I'm planning to release an App for iOS/Android that use SQLite as DB, but I want to do it multiuser not single user, is it possible to one Mobile device act as RemoteDB server for the rest of Android or iOS mobiles?

If so can you please point me in the right directions in order to configure one of my Mobile?

In theory you can run a RemoteDB server in mobile platform, using Indy-based server. I know some users do it.

But that's not an architecture I'd advocate for. Also, specifically for SQLite, you have to be careful with concurrency issues, RemoteDB creates one different connection for each client connected to it, I'm not sure it will work specifically for SQLite.

Give me a sample please, a basic Demo of an Android RemoteDB server maybe connected to a MySQL DB or SQLite that is much simple, I will research about concurrency settings in order to avoid any death locks.



What happend with the DEMO I requested?

We didn't have time to build it. We have a backlog that we work on.

I will wait until you have time



After 1 year and a half, is there possible you to build me a small sample of Android RemoteDB server just querying point B to point A, where A is the Android RemoteDB server.



I think next code works, however please take a look and feel free to recommend me some settings or approaches, the idea is to have an Android RemoteDB server connected at SQLite, and any kind of Windows, iOS or even Android clients, in a client-server environment.

Don't worry about DB concurrency, just give me all the information I need to know that TMS components allow me to do that.

// Inicializamos la variable
SparkleServer := nil;
ConexionBaseDatos := Nil;
ConexionServidorRemoteDB := Nil;

 // Creamos el servidor remoto
 SparkleServer := TIndySparkleHTTPServer.Create();
 SparkleServer.DefaultPort := 123;

 // Especificamos los datos de conexion
 ConexionBaseDatos := TDBConnectionFactory.Create(
      function: IDBConnection
           MiModuloDatos: TModuloDeDatos;
           MiModuloDatos := TModuloDeDatos.Create(Nil);
           Result := TFireDacConnectionAdapter.Create(ModuloDeDatos.ConexionLocalBD, MiModuloDatos);

 // Creamos la conexion RemoteDB
 ConexionServidorRemoteDB := TRemoteDBModule.Create('http://localhost:123/A/B', ConexionBaseDatos);
 ConexionServidorRemoteDB.UserName := '1';
 ConexionServidorRemoteDB.Password := '2';

 // Activamos el servidor remoto
 SparkleServer.Active := True;


That should work, there isn't much to be learned here compared to other platforms. Just follow the documentation about how to create an Indy server (which is what you did).


I tested the code and works well, however the code above it is on my DATAMODULE right now, do you recommend me to put the code on the main form, or it does not matter?

Also my actual App connect locally to SQLite and do a lot of DB procedures, it's a POS sale system, so the App will be used as an ordinary user an act as Server, do you think add the RemoteDB server will hang the App because of the workload? I mean put inside the RemoteDB Server in the same App a user works it really does not matter?

Finally, I see if Android device goes into suspend mode the RemoteDB server goes to, so nobody can connect using RemoteDB components, is there a way the TIndySparkleHTTPServer still working even if the Android device goes into suspension?


It doesn't matter, organize it as you wish and according to your application needs.

I don't know, you will have to test. SQLite is very fast and should handle lots of connections. They are all serialized, but it should take lot to medium workload. But it really depends on each case, obviously, there is always a limit.

I'm not expert in Android, but my guess is that doesn't relate to Indy components, but how you configure your Android application to work in the background or not. I believe it applies to any application regardless if it uses Indy or even if it's written in Delphi.


One final question.... for now

On my App I will validate a token for each RemoteDB user that want's to connect to the Android RemoteDB server, I will sale each extra mobile device to my user, how can I limit the use of RemoteDB if some user is not validated on a DBTable for example.

I mean I will create a DB table inside my SQLite Android RemoteDB server.

How can I limit a user who download my Client RemoteDB App and it's not on the DBTable of authorized devices?

Do you have some approach that allow me to intercept the connection of a Client from RemoteDB Cliente to RemoteDB Server?


I'm not sure if I understand what you want, but I guess it's just a matter of generating JWT tokens with proper information, and then in RemoteDB you add a middleware to reject requests according to the specific token content.

Exactly, did you have a sample of this?

Best Regards

Any existing Sparkle or XData sample that deals with JWT provides the same concept that can be applied to RemoteDB server. You can check the JwtAuthDemo for example. Or TMS Sphinx demo.

Thanks Sir

Thanks for the tip, I will review those demos.

However I was thinking to use the basic autentication combined with a SQLite DBTable that contains the authorized Android device ID like IMEI by example, on the Android RemoteDB Server my user must add the IMEI to the SQLite Table manually and then when the Client RemoteDB tries to connect at Server will send his IMEI + Basic username and password RemoteDB authentication + Username and Password credentials, if it does not exist on the SQLite DBTable of authorized devices simply denied the access even if RemoteDB authentication and Credentials are correct.

It's a very simple solution but I want to ask you if exists any security breach because finally the Authorized Device ID can be used by many users with it's own username and password credentials.

Thanks for all the information Wagner

Every security scheme has its breaches. It really depends on how secure you need your server. For example, a token can have a short expiration, thus if it's stolen, stealers will only be able to use them for a small amount of time. If a password is stolen, it can be used forever (until of course you change the password). Only you can answer if this is acceptable for your specific application.


I've issues with the Android RemoteDB server, I did not realise that once a RemoteDB Client is disconnected the Android RemoteDB server hangs.


I don't know what could be causing this. No further connection is allowed? If you use the RemoteDB administration API you does it still responds and you can see the existing connections?