Solved

Getting Android to access a simple MySQL database

Posted on 2013-01-18
8
609 Views
Last Modified: 2013-02-08
I have a MySQL database sitting behind a website that I own. What I want to do is create an Android app (for personal use only) which works as follows:

1. One screen with two buttons, A and B. No special graphics.
2. If you press button A, it accesses a table called 'countries' in the database and shows a screen of all columns in that table, of the rows where the 'country_initial' column contains an A.
3. If you press button B, it accesses the table called 'countries' and shows a screen of all columns in that table, of the rows where the 'country_initial' column contains a B.

I have full access to the database. The only table in the database I'm interested here is 'countries'.

I have been trying to work out how to do this (I know the basics of Java and have been fiddling about with the Android SDK but don't seem to be getting anywhere). It seems like a very simple thing to do, so if anyone can help me out (or point me to a tutorial that would help me with this) I'd be very grateful.

The simpler I can make it the better as I intend to learn how to do more complicated stuff from this example. Thanks.
0
Comment
Question by:cidlockie
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 17

Expert Comment

by:Chris Harte
ID: 38793100
I think you are coming from the wrong direction. Android apps are for accessing databases that are on the phone, usually SQLite. To access a database behind a website I would suggest you write a login page for mobiles then access it through the web browser on your phone.

Because the database you are using sounds very small, the best solution is to write your own app, since you also wish to learn how to code android.

This is a very good tutorial. Start at 1 and work your way through

http://thenewboston.org/list.php?cat=6

Databases are not addressed until video 111 but they are on average 5 mins long so you should be through the whole lot in a couple of days. You can even skip the ones about graphics and stuff you will not be using.
0
 

Author Comment

by:cidlockie
ID: 38793352
Thanks for that link, it does look useful for a number of things.

I get what you mean about the phone wanting to deal with a local SQLite database rather than a remote MySQL one. However, it seems a little pointless creating a web page that I then access through the browser of the phone, as the website itself can be accessed directly via the phone's browser.

It seems implausible that there's not some way to get small amounts of data out of a MySQL database to populate a simple Android application, even if there needs to be some SQLite step halfway between the two.
0
 
LVL 16

Expert Comment

by:Valeri
ID: 38793780
0
MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

 

Author Comment

by:cidlockie
ID: 38793879
Based on the comments at the bottom of the link I suspect it's probably not what I need (I'm no expert as I said), but I'll give it a go tomorrow, thanks.
0
 
LVL 17

Expert Comment

by:Chris Harte
ID: 38796475
This does what you want. (I think, I have not tried it, I am just assuming it works).

http://androiddevelopement.blogspot.co.uk/2011/09/connecting-to-remote-mysql-database.html

It also makes the point that you cannot connect directly to a remote server, you have to use a webservice and pass the data as a JSON object, via a php script. All other options seem to involve SOAP or setting up xml feeds.
0
 
LVL 15

Accepted Solution

by:
Ess Kay earned 500 total points
ID: 38807543
0
 

Author Comment

by:cidlockie
ID: 38843397
Apologies, this is still ongoing, I just haven't had time to try it out again yet.
0
 

Author Closing Comment

by:cidlockie
ID: 38867700
I think the second link in the accepted answer is going to prove closest to what I need here. Thanks to everyone for your replies.
0

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo‚Ķ
This post looks at MongoDB and MySQL, and covers high-level MongoDB strengths, weaknesses, features, and uses from the perspective of an SQL user.
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
This video teaches viewers about errors in exception handling.

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question