开发者

How to connect android to MySql database server?

开发者 https://www.devze.com 2023-03-24 22:50 出处:网络
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.

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!


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.


try using Jdbc... for more read this http://developer.android.com/reference/java/sql/package-summary.html

0

精彩评论

暂无评论...
验证码 换一张
取 消