使用Android的RESTful服务

使用Android的RESTful服务

问题描述:

I can't seem to get a grasp on getting the web-to-android concept. I was reading a bunch of stuff about RESTful services and JSON, but I never found anything that could help me. My idea is to have Access database somewhere online, and get files from it on the android app.

Where should I even begin? Say I got the DB and i got the server to put it on. Where does JSON come in play? Where are queries put into, some PHP, JSON, app itself?

As far as I could understand from all I have read, the connection should be somehow like this

WEB -- Database -- REST -- App

How does it connect to PHP, where does the PHP file go? I have seen many topics here talking about it, but everyone has already made SOME progress, I don't know where to even start. Could you direct me to some book worth reading?

Thank you

我似乎无法掌握获取web-to-android的概念。 我正在阅读有关RESTful服务和JSON的一些内容,但我从来没有找到任何可以帮助我的东西。 我的想法是让Access数据库在线,并在Android应用程序上从中获取文件。 p>

我应该从哪里开始? 说我得到了数据库,我得到了服务器来启用它。 JSON在哪里发挥作用? 查询放在哪里,一些PHP,JSON,应用程序本身? p>

据我所知,从我所读过的所有内容来看,连接应该是这样的 p>

WEB - 数据库 - REST - 应用程序 p>

它如何连接到PHP,PHP文件在哪里? 我在这里看到很多关于它的话题,但是每个人都已经取得了一些进展,我不知道从哪里开始。 你能指导一些值得阅读的书吗? p>

谢谢 p> div>

In simple JSON (JavaScript Object Notation) is a lightweight format that is used for data interchanging. see here for information.

You will have two ends for your project, the front end (android side) and the back end(the server & php). JSON is the way the two ends talk.

You asked how does it, i assume you mean the java code for the android side, connect to the PHP. The PHP is the language you are writing your API for JSON requests in.

How does your java code use the api? You use REST and made HTTP POST or GET requests depending on your need.

This article shows how to connect them together.

EDIT

The overall structure is the following:

-- Create db
-- Put db on server 
-- create PHP webservice to fetch from db and encode in JSON
-- use REST to make HTTP requests to get data from the database
-- data comes back in JSON 
-- decode JSON (using standard librarys in java)
-- use your data

Hopefully this helps

Thank you