title: Old listview data will be clear and reset again new data when getdata button is clicked again in android
body: <p>I'm fresher to android. I created android <code>ListView</code> using JSON WebService. I want old ListView data to be clear and reset again new data when <code>getdata</code> button is clicked again . Help me, thanks in advance.</p>
  
  <pre><code>    setContentView(R.layout.activity_main);
      CargoTracklist = new ArrayList&lt;HashMap&lt;String, String&gt;&gt;();
  
     Btngetdata = (Button)findViewById(R.id.button1);
      Btngetdata.setOnClickListener(new View.OnClickListener() {          
          @Override
          public void onClick(View view) {            
               new JSONParse().execute();             
          }
      });                
  }    
  private class JSONParse extends AsyncTask&lt;String, String, JSONObject&gt; {
       private ProgressDialog pDialog;
      @Override
      protected void onPreExecute() {
          super.onPreExecute();          
           Status = (TextView)findViewById(R.id.textView2);
           Id= (TextView)findViewById(R.id.textView1);
           DateTime = (TextView)findViewById(R.id.textView3);
           JobNo =(EditText)findViewById(R.id.editText1);
          pDialog = new ProgressDialog(MainActivity.this);
          pDialog.setMessage("Getting Data ...");
          pDialog.setIndeterminate(false);
          pDialog.setCancelable(true);
          pDialog.show();
  
  }       
  @Override
      protected JSONObject doInBackground(String... args) {
                      JSONParser jParser = new JSONParser();
                   ArrayList&lt;BasicNameValuePair&gt; params = new ArrayList&lt;BasicNameValuePair&gt;();
          params.clear();         
           params.add(new BasicNameValuePair("JobNo",JobNo.getText().toString()));
  
                // Getting JSON from URL
                JSONObject json = jParser.getJSONFromUrl(url,params);
                return json;                            
      }                   
       @Override
       protected void onPostExecute(JSONObject json) {
           pDialog.dismiss();
           try {
               if (JobNo.getText().toString().equals(""))
                  {
                      Toast.makeText(MainActivity.this, "You did not enter a JobNo", Toast.LENGTH_SHORT).show();
  
                   }
                   else                    {                               
               // Getting JSON Array from URL
                  Cargo = json.getJSONArray(TAG_CargoTrack);
                  for(int i = 0; i &lt; Cargo.length(); i++){
                  JSONObject c = Cargo.getJSONObject(i);
  
                  // Storing  JSON item in a Variable
                  String Status = c.getString(TAG_Status);
                  String Id = c.getString(TAG_Id);
                  String DateTime = c.getString(TAG_DateTime);                                                                                        HashMap&lt;String, String&gt; map = new HashMap&lt;String, String&gt;();
  
                  map.put(TAG_Status, Status);
                  map.put(TAG_Id, Id);
                  map.put(TAG_DateTime, DateTime);
  
                  CargoTracklist.add(map);
                  list=(ListView)findViewById(R.id.listView1);
                                                                                      ListAdapter adapter = new SimpleAdapter(MainActivity.this, CargoTracklist,
                          R.layout.listview,
                          new String[] { TAG_Status,TAG_Id, TAG_DateTime }, new int[] {
                                  R.id.textView2,R.id.textView1, R.id.textView3});
  
                  list.setAdapter(adapter);
                  list.setOnItemClickListener(new AdapterView.OnItemClickListener() {
  
                      @Override
                      public void onItemClick(AdapterView&lt;?&gt; parent, View view,
                                              int position, long id) {
                          Toast.makeText(MainActivity.this, "You Clicked at "+CargoTracklist.get(+position).get("Id"), Toast.LENGTH_SHORT).show();
  
                      }
                  });
  </code></pre>