Solved

Getting Android to access a simple MySQL database

Posted on 2013-01-18
8
606 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
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
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
String array comparison 4 34
MySQL Backup Strategy 15 25
Complex SQL statement in VB.NET 7 15
moto 4g file transfer 12 9
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

803 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