Jivan
Jivan

Reputation: 1320

How to access online mysql database in android?

I have created an online database about the restaurants and I need to access this database through my android application, so that I can display the data to the users after filtering. My application does not need to update the database, but my problem is how to connect to my online mysql database and provide it to the users? I have looked on many suggestions on this site as well as on others, and I just found I have to use JSON parser while accessing but do not how to do it.

Upvotes: 7

Views: 28333

Answers (3)

Cool Compiler
Cool Compiler

Reputation: 857

This link might help you . http://www.androidhive.info/2012/01/android-login-and-registration-with-php-mysql-and-sqlite/ Just get an understanding of JSON parsers and how it can be used in android for retrieving data from database on server... you can write webservices in php..

Upvotes: 4

biddulph.r
biddulph.r

Reputation: 5266

You need to provide a server side solution that the Android application can speak to. PHP scripts are a good way to go, that can directly interface with the MySQL database, and return results to the device.

You can then be creative with the PHP script, by sorting the results etc, and providing a more comprehensive solution by taking away some of the processing from the Android device, and doing it server side where battery life isn't as much of a problem.

You simply need to implement web service calls on the Android device, simple GET/POST requests over HTTP suffice depending on what you intend to do. Have a look into REST APIs for guidelines on how to implement properly.

You can easily add a PHP script to the same server as the MySQL database for this

Upvotes: 0

Stefano Ortisi
Stefano Ortisi

Reputation: 5336

The best solution is provide a public API, managed for example with PHP, which delivers your database data filtered and displayed as your Android application needs.

Upvotes: 7

Related Questions