19

I've been doing my own research but to no avail. I am doing an android app which contains listviews and it needs to query data from a remote database. I would really appreciate it if someone could share good tutorial links that teach that kind of stuff. Sorry, I know this isn't a proper question but I really need some help. Thanks.

Emil
  • 7,220
  • 17
  • 76
  • 135
Tiara Zarin
  • 207
  • 1
  • 2
  • 8
  • 5
    You really don't want to communicate with the database directly, primarily for security reasons. Ideally, you'll want to set up a web service to communicate with the DB and and serve data from it to your app. See this tutorial:http://www.vogella.com/articles/REST/article.html – drew moore May 23 '13 at 02:35
  • possible duplicate of [How to set up a connection with remote database in android?](http://stackoverflow.com/questions/3092095/how-to-set-up-a-connection-with-remote-database-in-android) – ChrisGPT was on strike Feb 25 '14 at 01:54

4 Answers4

10

You can refer to this tutorial

Or refer to this diagram

MDMalik
  • 3,951
  • 2
  • 25
  • 39
3

How about a simple web service in the middle?

It helps to prevent you putting database username/pw directly in the app too.

App -> Http requests -> Web service -> Database

The Http requests can be done via Android HttpClient

The web service can be in php for example. (There is a lot example for php to database on google.)

Calvin
  • 3,302
  • 2
  • 32
  • 41
3

To communicate with the remote databse, you require web service which can fetch data from or suit data to remote database.

I am not sure about which web platforms are you using currently but I would suggest you to go with REST with JSON.

Paresh Mayani
  • 127,700
  • 71
  • 241
  • 295
1

This is the typical case of SyncAdapter with it you can use the remote database from your content provider as a regular DB.

I have done it and it works well with only few complexities.

rock_win
  • 755
  • 1
  • 5
  • 14