Display records in list view
<p>Please help me in this code i am able to fetch the values from my database and store it in records(Array of strings) when i try to show it in list view it is stopping and give run time error</p>

<pre><code>public class requests extends Activity {

private ListView lv;
ArrayAdapter&lt;String&gt; adapter;
JSONParser jParser = new JSONParser();  
private static String url_all_products = "http://10.0.2.2/my_sql/get_requests.php";
String name;

final ArrayList&lt;String&gt; records = new ArrayList&lt;String&gt;();
ArrayList&lt;HashMap&lt;String, String&gt;&gt; productsList;
JSONArray products = null;
// JSON Node names

private static final String TAG_SUCCESS = "success";
private static final String TAG_PRODUCTS = "products";
private static final String TAG_USERID = "Userid";
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.requests);
     name= getIntent().getExtras().getString("Name");


   int i;


   new LoadAllProducts().execute();   
    lv = (ListView) findViewById(R.id.list);


}

class LoadAllProducts extends AsyncTask&lt;String, String, String&gt; {

    /**
     * Before starting background thread Show Progress Dialog
     * */
    @Override
    /*protected void onPreExecute() {
        super.onPreExecute();
        pDialog = new ProgressDialog(MainActivity.this);
        pDialog.setMessage("Authenticating...");
        pDialog.setIndeterminate(false);
        pDialog.setCancelable(false);
        pDialog.show();
    }*/

    /**
     * getting All products from url
     * */
    protected String doInBackground(String... args) {
        // Building Parameters
        List&lt;NameValuePair&gt; params = new ArrayList&lt;NameValuePair&gt;();
        params.add(new BasicNameValuePair("fname",name));
        // getting JSON string from URL
        JSONObject json = jParser.makeHttpRequest(url_all_products, "GET", params);

        // Check your log cat for JSON reponse
        Log.d("USERS: ", json.toString());

        try {
            // Checking for SUCCESS TAG
            int success = json.getInt(TAG_SUCCESS);

            if (success == 1) {
                // products found
                // Getting Array of Products
                products = json.getJSONArray(TAG_PRODUCTS);

                // looping through All Products
                for (int i = 0; i &lt; products.length(); i++) {
                    JSONObject c = products.getJSONObject(i);

                    // Storing each json item in variable

                    String fname = c.getString(TAG_USERID);
                    records.add(fname);
                    System.out.println("Request list " + records);
                    // creating new HashMap
                    /*HashMap&lt;String, String&gt; map = new HashMap&lt;String, String&gt;();

                    // adding each child node to HashMap key =&gt; value

                    map.put(TAG_FNAME, fname);

                    // adding HashList to ArrayList
                    productsList.add(map);
                    records.add(fname);
                    System.out.println("Reqvalues : "+ productsList);
                    System.out.println("Request list " + records);*/



                }


                callListview(records);



            } else {
                // no products found
                // Launch Add New product Activity
                Intent i = new Intent(getApplicationContext(),
                        planner.class);
                // Closing all previous activities
                i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                startActivity(i);
            }
        } catch (JSONException e) {
            e.printStackTrace();
        }



        return null;
    }

    private void callListview(ArrayList&lt;String&gt; records) {
        // TODO Auto-generated method stub

        System.out.println(records);
        adapter = new ArrayAdapter&lt;String&gt;(requests.this, R.layout.list_item, R.id.product_name, records);
        //adapter = new ArrayAdapter&lt;String&gt;(this, R.layout.list_item, R.id.product_name, products);
        lv.setAdapter(adapter);



    }
}



}
</code></pre>
