Reputation: 21
Hi guys I´m pretty much a begginer in Android. This is the situation. I´m trying to write an app which basically obtains data from a website an displays it in the App, the data from the website is PHP and I´m confuse in how to do it, I heard about json, and parsing in xml but I just don´t know how to do it. What should I use to parse the data? and how?, somebody told me about AMF but I have no idea what is that, so can somebody help me with this, an example "begginer friendly" would be appreciated. Thanks guys!!
Upvotes: 2
Views: 6555
Reputation: 773
First let's think about it, what will be the flow of your combined (Android + PHP) application?
I would recommend using Google: take the points I wrote and ask Google questions about how to accomplish every one of them.
Search engine keywords:
Always when you face a big problem (also in real life) try to:
Well - so I didn't give you the answer to your questions but I believe that I showed you a possible path for a solution.
P.S. - stackoverflow is a home for many professionals (not counting myself...). They invest a lot of time and effort in their own problems and are very kind in trying to help others. Always show them that you are willing to invest efforts in solving your own problems - otherwise you might discourage them too quickly :-)
Tons of luck!
Upvotes: 4
Reputation: 8477
You need to clarify your question. The fact that the web site is powered by PHP is irrelevant, unless you are writing it. You have an HTTP interface to your data. You need to fetch things into your Android client using HTTP. That's the first example you need.
URL url = null;
HttpURLConnection urlConnection = null;
try {
// Fetch URL
url = formatQuery( "this part is up to you" );
while (url != null) {
urlConnection = (HttpURLConnection) url.openConnection();
InputStream is = urlConnection.getInputStream();
InputStreamReader isr = new InputStreamReader(is);
parseResult( isr );
url = null;
}
} catch (MalformedURLException e) {
} catch (IOException e) {
} finally {
urlConnection.disconnect();
}
The next question is, what format is the data in that is returned by the PHP app? Is it JSON or XML? That's not covered by your question, so I suggest you figure out which it is, and pursue the appropriate path. If you need to ask a second question, do that.
Upvotes: 2
Reputation: 4506
Read this article. You can get idea of retrieving data from php/mysql: http://www.androidhive.info/2012/05/how-to-connect-android-with-php-mysql/ http://www.androidhive.info/2011/11/android-xml-parsing-tutorial/
Upvotes: 2