How to retrieve value from Arraylist and post JSON data from android
<p>I have ArrayList <strong>itemforinvoice</strong> which contains value for keys name, description, quantity, unit_cost etc. 
Now I want to retrieve these values in for loop and assign to these values to keys.. I have provided code given below ..Please suggest. </p>

<pre><code> public class JSONParserCreateInvoice {

    static InputStream is = null;
    static JSONObject jObj = null;
    static String json = "";

    // constructor
    public JSONParserCreateInvoice() {}

    public JSONObject getJSONFromUrl(String url,String tokenid, String clientid, String title,String date, String latefee,String duedate, String scheduledate,ArrayList itemforinvoice) 

    {

      // Making HTTP request

            try {

      // defaultHttpClient

                DefaultHttpClient httpClient = new DefaultHttpClient();
                HttpPost httpPost = new HttpPost(url);

                JSONObject CreateInvoice = new JSONObject ();

                CreateInvoice.put("client_id", clientid);
                CreateInvoice.put("invoice_title",title);
                CreateInvoice.put("date", date);
                CreateInvoice.put("late_fee",latefee);
                CreateInvoice.put("due_date", duedate);
                CreateInvoice.put("schedule_date",scheduledate);

                JSONObject obj1;
                JSONArray itemsarray = new JSONArray();
                JSONObject createInvoiceobj = new JSONObject ();

                try {
                    for(int i=0;i&lt;itemforinvoice.size();i++)
                    {
                        obj1 = new JSONObject();

                       obj1.put("name","");
                       obj1.put("description", "");
                       obj1.put("quantity", "");
                       obj1.put("unit_cost", "");
                       obj1.put("discount",  "");
                       obj1.put("tax1_name", "");
                       obj1.put("tax2_name", "");

                       itemsarray.put(obj1);
                    }   
                    CreateInvoice.put("items",itemsarray);

                } catch (JSONException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }

                createInvoiceobj.put("createInvoice", CreateInvoice);
</code></pre>
