0

So I have a website which is running a MySql server. Now I want to use the MySql for my android application.

My question is how to do this? I did some search and it seem i need to create a web service and somehow expose the MySql via REST or something similar.

Can you please explain how can i do that? And is there a better way to do this ?

rtp
  • 794
  • 1
  • 10
  • 26

2 Answers2

1

There are lot's of tutorials on this. Since you are not very specific. Here are some links that you can check for tutorials on this.

Connecting to MySQL database

Login and Registration with PHP / MYSQL - Android

Connect android with PHP & MySQL

Wesley
  • 1,808
  • 5
  • 31
  • 46
0

It depends on what type of website that you have. The ideal solution is to offer web services as you said and only those web services will have access to the database. If you give direct MySql access to the mobile application, anyone can connect to your database and can mess around with the data which is something you would want to avoid.

Depending on the technology you are using for the website, there are a great number of blogs, articles and tutorials on how to develop REST web services which should be easy to follow.

On the android side, you can either program the REST requests or you can use existing libraries that offer these functionalities such as Spring Mobile

aseychell
  • 1,794
  • 17
  • 35
  • how can restrict access to my web services? do i need to be connected to the database to use the webserves ? and on the php how do i make a webservice that java rest can talk with ? – rtp Jul 14 '12 at 08:03
  • Your php connects with mySQL db on the web end and encodes, data through JSON response. You can retrieve that response from android and parse it. – Wesley Jul 14 '12 at 08:06
  • it depends on the technology that you are using for web services, but for all cases, there are different ways you can secure rest web services using standard HTTP security approaches, such as token based security, login, etc. – aseychell Jul 14 '12 at 08:07
  • This question is related to calling REST webservices from android : http://stackoverflow.com/questions/6047194/how-to-call-restful-web-service-from-android?rq=1 – aseychell Jul 14 '12 at 08:11