6

I've been looking for a week now... I need some help connecting to a remote database... I want my app to get data out of the database and update the database... I've tried this but i don't understand it.

lmo
  • 37,904
  • 9
  • 56
  • 69
sakkie
  • 69
  • 1
  • 1
  • 2

3 Answers3

7

Easiest way to connect a Mobile (ANDROID, iPhone, Symbian, WP7, you name it) device to a Data Base is to write a HTTP based proxy for your database.

This is:

ANDROID -> HTTP -> APPLICATION SERVER -> DATABASE

And then the other way around to get results:

DATABASE -> APPLICATION SERVER -> HTTP -> ANDROID

In this scenario, you will write a HTTP based application in your favorite language (PHP, Python, Perl, Java, .NET) and deploy it in your favorite Application Server (Apache, Tomcat, IIS) and, in that application you will publish URLs your Android app will access to send/retrieve data to your database.

Pablo Santa Cruz
  • 176,835
  • 32
  • 241
  • 292
  • is it possible to give me an example plz – sakkie Nov 08 '10 at 14:45
  • i understand what your saying...im new to programming...so i need a example of how to do this... – sakkie Nov 09 '10 at 06:27
  • does any one have a sample program that i can have a look at please? – sakkie Nov 09 '10 at 13:09
  • @sakkie. do you know how to write a WebServer APP that will get data from a DataBase? – Pablo Santa Cruz Nov 09 '10 at 14:34
  • @pablo. no i dont know. can you help me plz – sakkie Nov 10 '10 at 07:03
  • @sakkie: OK. Start by learning how to do a very simple WebServer APP. Pick a language. There are plenty of tutorials on the NET. – Pablo Santa Cruz Nov 10 '10 at 11:02
  • @pablo...i tried this...but got nowhere...im really new to programming...so if you cant help me with sample app then i guess i might give up even before i really started... – sakkie Nov 12 '10 at 10:02
  • 1
    @sakkie never just give up. Sample apps are great, but they're not the be all end all. I'm new to android programming as well and it's a big learning process. When I learned php I had to sit down with a book (learn php in 24 hours) and read and go through the entire book to understand. There are a lot of tutorials to show you have to use php to access a database. You'll have to learn the basics before a sample script would be any use to you. Take a weekend and go through a book on php (or another language, I just like php myself). – Shannon Cole May 03 '12 at 13:27
3
  1. Create the database in the server
  2. Write server side program to store and retrieve data
  3. write the android program to access the data using HttpPost class

All the best...

Murali-Hassan
  • 81
  • 1
  • 1
3

I think rather than connect to a database remotely, you want to use REST services to get and post data to your remote database.  

You can create a REST service to wrap your remote database query and return via http, JSON (which I prefer) or XML.

In your android app you can do an http get or post to consume the aforementioned service

Atma
  • 29,141
  • 56
  • 198
  • 299