[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 612
  • Last Modified:

Getting Android to access a simple MySQL database

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
cidlockie
Asked:
cidlockie
1 Solution
 
Chris HarteThaumaturgeCommented:
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
 
cidlockieAuthor Commented:
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
 
ValeriCommented:
0
Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

 
cidlockieAuthor Commented:
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
 
Chris HarteThaumaturgeCommented:
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
 
Ess KayEntrapenuerCommented:
0
 
cidlockieAuthor Commented:
Apologies, this is still ongoing, I just haven't had time to try it out again yet.
0
 
cidlockieAuthor Commented:
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now