title: Adapt data to ListView
body: <p>In one of my activity I have <code>EditText</code>, Submit <code>Button</code> and a <code>ListView</code>. The data of <code>ListView</code> are retrived from database. To retrive data from database and adapt to <code>ListView</code> I used the following code.</p>
  
  <pre><code>private void loadList() {
      mylist = new ArrayList&lt;HashMap&lt;String, Object&gt;&gt;();
      mylist.clear();
      List&lt;Data&gt; catDesc = dbhelper.getCatMasterDesc(id);
      ArrayAdapter&lt;Data&gt; adapter = new SimpleAdapter(getApplicationContext(), R.layout.list, catDesc);
      lv1 = (ListView) findViewById(R.id.masListView1);
      lv1.setAdapter(adapter);
  }
  </code></pre>
  
  <p>And i call this method every time whenever I update the database to show updated listview.</p>
  
  <pre><code>String str = category.getText().toString();
  yes.setOnClickListener(new OnClickListener() {
      public void onClick(View arg0) {
      dbhelper.UpdateMasterDesc(str);
      loadList(); // see here.
  }
  });
  </code></pre>
  
  <p>This is the way I am updating my <code>ListView</code>. I think this is not a good way. If yes means please suggest me how can I update my <code>ListView</code> Whenever I update the database.</p>
  
  <p>Thank You.</p>