Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to connect android to MySql database server?

Tags:

android

In my project, I have to connect an Android mobile phone to a remote MySQL database server, to insert data to the database and get the data back later.

However, it seems that Android OS only supports the SQLLite database that works LOCALLY inside the phone.

Does anyone know how to connect an Android phone to a remote MySQL (or MSSQL, or Oracle) database server ?

Thank you!

like image 869
suresh Avatar asked Nov 05 '22 16:11

suresh


1 Answers

You will have to access the database using some sort of Remote Method Invocation (RMI).

My personal recommendation is to create a RESTful HTTP interface to your MySQL database on the server. This may be a bit more work, but is preferred for its ease of use and compatibility with any system (that can make an HTTP request that is).

Essentially, you should create HTTP endpoints to Create, Read, Update, Delete (CRUD) data from your MySQL database on your server. Your Android client would then make calls to these HTTP endpoints to perform the corresponding CRUD operations. Of course you do not need to do the typical CRUD operations, you can make your endpoints interact with the database however you wish.

Like I said, a big advantage to this is how extensible it is. You can create another client, on another system, in another language, and all you need to do is make the proper HTTP call.

like image 72
nicholas.hauschild Avatar answered Nov 15 '22 05:11

nicholas.hauschild