Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Connecting to external database - Android application

I am writing an application for my third year project. The application will require interaction with an external mySQL database. The application will retrieve data from the database and display it to the user in a ListView.

I have a good idea of what sort of functionality the application is going to have. I also have spent a lot of time working with ListViews and the local SQLite database. I also did a bit of reserach into the HttpUrlConnection class.

I am just wondering would anyone be able to offer me a little bit more guidance as to how I might go about accessing this external database?

Will it involve me having to write a web service to handle the transactions? and if so what would that involve as I have not encountered web services in my course just yet.

Any advice would be much appreciated. Also my application is intended for use on ICS v4.0.4.

Thanks everyone!

like image 754
Javacadabra Avatar asked Oct 09 '12 17:10

Javacadabra


People also ask

How can you connect to a database from an application?

Applications get a database connection from a connection pool by looking up a data source using the Java Naming and Directory Interface (JNDI) and then requesting a connection. The connection pool associated with the data source provides the connection for the application.

Can Android app connect to MySQL database?

Android does not support MySQL out of the box. The "normal" way to access your database would be to put a Restful server in front of it and use the HTTPS protocol to connect to the Restful front end.


1 Answers

Yes you have to create Web Service to interact with External Database (MySql in your case). Its very easy to create Web service in PHP as its having one function which convert your DB data to JSON and you can easily parse the JSON data and display that in Listview or accordingly your requirement.

Here are some useful link which will help you to get more details :-

http://www.androidhive.info/2012/05/how-to-connect-android-with-php-mysql/ - Best from All

http://www.coderzheaven.com/2011/04/08/android-phpmysql-connection/

http://blog.sptechnolab.com/2011/02/10/android/android-connecting-to-mysql-using-php/

Hope it helps.

like image 124
Scorpion Avatar answered Sep 19 '22 13:09

Scorpion