/** * Make a request for data call to restful * * @param uri * @throws JSONException */ private void requestData(String uri) throws JSONException { RequestPackaging p = new RequestPackaging(); p.setMethod("POST"); // Set the HTTP REQUEST method p.setUri(uri); // Sets the URI JSONArray jar = new JSONArray(); JSONObject object = new JSONObject(); object.put("query", "select"); // What kind of query object.put("method", "getborrowedbooks"); // What kind of request object.put( "id", SaveSharedPreference.getID(getActivity())); // Pass the id for the user to the webservice jar.put(object); p.setJarParams(jar); // Add the param objects to the JSONArray MyTask task = new MyTask(); task.execute(p); }
private void requestUpdateData(String uri) throws JSONException { for (Book b : adapter.getSelectedBooks()) { BorrowedBook bb = (BorrowedBook) b; RequestPackaging p = new RequestPackaging(); p.setMethod("POST"); // Set the HTTP REQUEST method p.setUri(uri); // Sets the URI JSONArray jar = new JSONArray(); JSONObject object = new JSONObject(); object.put("query", "update"); // What kind of query object.put("method", "retrieveborrowbook"); // What kind of request object.put( "id", SaveSharedPreference.getID(getActivity())); // Pass the id for the user to the webservice object.put("isbn", bb.getIsbn()); object.put("friendid", bb.getOwner().getId()); jar.put(object); p.setJarParams(jar); // Add the param objects to the JSONArray MyTask task = new MyTask(); task.execute(p); } }