开发者

Android application that gets data from a remote database

I am attempting to write an Android application that will use the publisher/subscriber model to get data from a database that will be hosted on some remote server. This is a prototype application so I am just going to host the server on my home PC. I am using Ubuntu. I have read and researched this topic but there is a wide array of scattered answers. I have a lot of questions dealing with this but for starters..

  • What is the best method for hosting a server that contains a database, to use with android?
  • does it matter what type of database I use?
  • Can I use the android SQLite APIs for getting data from the d开发者_JAVA技巧atabase

I read in multiple places that it is not kosher to connect to a database from anything over the internet directly, especially from a mobile device. So I think I need to use some sort of HTTP, REST or something of the sort.


What is the best method for hosting a server that contains a database?

From the standpoint of server communicating with database, normally there is no difference whether it is Android or any other client. What is important is that you define well protocol of communicating between server and client (Android in your case). The best probably would be some http based protocol (REST may be).

does it matter what type of database I use?

For the client it does not matter. Android will be just another client. So it does not matter for you. Choose the one that is easiest to get going and well adopted. MySql, Postgres are good candidates.

Can I use the android SQLite APIs for getting data from the database.

No

I read in multiple places that it is not kosher to connect to a database from anything over the internet directly

You surely don't want to do it. More importantly, when you design your server you may want to separate code that talks to the database from code that talks to your client. That would be a basis of service oriented architecture.


Android app to connect to backend database / website

How to communicate with server's database from android phone?

These two questions have some good ideas.

What I would do is create a Restful web application. One where your CRUD db operations can be expressed through your HTTP methods.

  1. Create - POST/PUT
  2. Read - GET
  3. Update - POST/PUT
  4. Delete - DELETE

From the web side you could simply use JDBC to perform your db operations.

This is quite a simple suggestion, but I think it suggests a good starting point. (Perhaps this is obvious, but you would definitely want to authenticate requests coming in, as to prevent malicious attacks on your data.)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜