简体   繁体   中英

RESTful service with Android

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM