How to connect an android app to a remote database

2019-01-16 13:20发布

问题:

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.

回答1:

You can refer to this tutorial

Or refer to this



回答2:

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.



回答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.)



回答4:

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.