Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
142 views
in Technique[技术] by (71.8m points)

(need advice) Talk to MySQL server database from my Android App

I am starting my thesis which is an app for android. This app is based on a web platform I had created.

The part where I need advice is: which is the most efficient way to pull data from a MySQL server into the application. Please give me some advice and your experience on the matter.

(I've read about encoding the queries in json, but it seems like awful lot of needless work)

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I suggest you to use RESTful Web Service in Java using Jersey as an intermediate layer between you Android App and MySQL server. You can transfer data in JSON (my suggestion for a mobile app), xml or palin text to your Android App.

You can find the benefits of using Web Service in you system in @Elad answer : Best way to access a remote database: via webservice or direct DB-access?

Also later if you decide to develop other smart phone platform for your system, you just need to reuse the same Web Service. As a result this Web service can be considered as a generic protocol for the mobile user of your system.

I used Hibernate to map the data to MySQL database. RESTful Service Using Jersey with Hibernate Persistence

If you decide to follow this approach note that it is highly recommended to separate your hibernate stuff form your Jersey services. You need to wire your DAO to your Service tier. see what @Rick Mangi wrote to me : REST with Java (JAX-RS) using Jersey and hibernate

It is also good approach to use HTTP Client in your Android App, Since it supports @GET, @POST, @DELETE and @PUT commands and you can easily talk to your database like HTTP GET Request


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...