Reputation: 105
I am new to LoopJ Android Asynchronous-Http-Client. I figured out how to use my web service to POST to the database but now I cannot figure out how to GET the data from the database with my PHP web service. I need to obtain all the information in an entire Table and I know that I need to parse the information once it is received. I have this for a POST:
AsyncClient.CreatePost("create_entry.php", null,
new JsonHttpResponseHandler());
Is the GET similar to this?
AsyncClient.GetPost("retrieve_entry.php", null,
new JsonHttpResponseHandler());
Once I GET the data where is the information stored so that I can display it to the user? I am lost. I have looked around and I can't seem to find the proper documentation. Help!
Upvotes: 1
Views: 1101
Reputation: 155
Look man after get this data you can cache it or simple display it, the callbacks are invoked on UI thread but the network is out of UI thread, I recommend use JSON to get the data and serialize into models using Jackson or Gson.
The information is not stored, it's in memory you need override one of the callbacks and get these results on onsuccess callback on AsyncHttpResponseHandler.
Upvotes: 1
Reputation: 12042
You can make a call to the HttpGet method from the loopj like this
AsyncHttpClient client = new AsyncHttpClient();
client.get("retrieve_entry.php",null, new JsonHttpResponseHandler() {
@Override
public void onSuccess(String response) {
log.e("Response",response);
}
@Override
public void onFailure(Throwable e, JSONArray errorResponse) {
Log.e(TAG, "OnFailure!", e);
}
});
Upvotes: 1