title: How to refresh listview when click delete button
body: <p>I have delete coding in <strong>adapter class</strong> as below:</p>
  
  <pre><code>delBtn=(ImageButton) v.findViewById(R.id.del_btn);  
  delBtn.setOnClickListener(new View.OnClickListener() {
  
      @Override
      public void onClick(View v) {
          sqlCon.deleteItem(id);          
      }
  }); 
  </code></pre>
  
  <p>and here is the code in <strong>sqliteconnection class</strong>,</p>
  
  <pre><code>public void deleteItem(long id) {
      System.out.println("DELETE ");
      db = sqlHp.getWritableDatabase();
      db.delete(ItemDb.TABLE, "_id="+id , null);
      db.close();
  }   
  </code></pre>
  
  <p>How can I refresh the listview when click the <strong>delete</strong> button? Thanks.</p>
  
  <p><strong>EDIT</strong>
  *<em>In class A</em>*</p>
  
  <pre><code> public Cursor getAllItem(String user) {
  
      String[] userID = new String[] {user};
  
  
      db = sqlHp.getReadableDatabase();       
      cur=db.query(ItemDb.TABLE, null, "user=?", userID, null, null, "name");     
      return cur;
  
  }
  
  public Cursor getOneItem(long id) {
      db = sqlHp.getReadableDatabase();
      cur=db.query(ItemDb.TABLE, null, "_id="+ id, null, null, null,null);
      return cur;
  }
  </code></pre>
  
  <p><strong>The class C:</strong></p>
  
  <pre><code>@Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState); 
  
          String[] from = new String[] { ItemDb.NAME, ItemDb.CONDITION, ItemDb.EMAIL};
          int[] to = new int[] { R.id.etItemName, R.id.etItemCondition, R.id.etEmail };
          itemAdapter = new ItemAdapter(this,R.layout.list_item, null, from, to);
          this.setListAdapter(itemAdapter);
  
          UserName = (String) getIntent().getSerializableExtra("UserName");
  
          SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
          SharedPreferences.Editor editor = settings.edit();
          editor.putString("UserName", UserName); // here string is the value you want to save
          editor.commit();                  
          Log.i(Tag, "UserName1: "+ UserName);
      }
  </code></pre>
  
  <p>another part of Class C</p>
  
  <pre><code>@Override
      protected void onResume() {
          super.onResume();
          new GetItem().execute((Object[]) null);
      }
  
      @SuppressWarnings("deprecation")
      @Override
      protected void onStop() {
          Cursor cursor = itemAdapter.getCursor();
  
          if (cursor != null)
              cursor.deactivate();
  
          itemAdapter.changeCursor(null); 
          super.onStop();
  
      }
  
      private class GetItem extends AsyncTask&lt;Object, Object, Cursor&gt; {
          ItemSQLiteConnector dbConnector = new ItemSQLiteConnector(ItemActivity.this);
  
          @Override
          protected Cursor doInBackground(Object... params) {
              return dbConnector.getAllItem(UserName);
          }
  
          @Override
          protected void onPostExecute(Cursor result) {
              itemAdapter.changeCursor(result);           
          }
  
      }
  
      @Override
      public boolean onCreateOptionsMenu(Menu menu) {
          getMenuInflater().inflate(R.menu.activity_item, menu);      
          return true;
      }
  
      @Override
      public boolean onOptionsItemSelected(MenuItem item) {       
          Intent addItem = new Intent(ItemActivity.this, AddEditItem.class).setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  
          startActivity(addItem);     
          return super.onOptionsItemSelected(item);
  
      }
  
  }
  </code></pre>
  
  <p>Class B:</p>
  
  <pre><code>public class ItemAdapter extends SimpleCursorAdapter {
  
      private int layout;
      private ImageButton editBtn;
      private ImageButton delBtn;
      ImageButton addBtn;
      String selection, UserName;
      LayoutInflater inflator;
      final ItemAdapter myadapter = this;
      private SQLiteDatabase db;
  
  
  
      public ItemAdapter(Context context, int layout, Cursor c,String[] from, int[] to) {
          super(context, layout, c, from, to,0);
          this.layout = layout;
          inflator= LayoutInflater.from(context);
  
  
      }
  
      public View newView(Context context, Cursor cursor, ViewGroup parent) {     
          View v = inflator.inflate(layout, parent, false);       
          return v;
  
      }
  
      @Override
      public void bindView(View v, final Context context, Cursor c) {
          final int id = c.getInt(c.getColumnIndex(ItemDb.ID));
          final String user = c.getString(c.getColumnIndex(ItemDb.USER));
          final String name = c.getString(c.getColumnIndex(ItemDb.NAME));
          final String condition = c.getString(c.getColumnIndex(ItemDb.CONDITION));
          final String email = c.getString(c.getColumnIndex(ItemDb.EMAIL));
          final String category = c.getString(c.getColumnIndex(ItemDb.CATEGORY));
          final byte[] image = c.getBlob(c.getColumnIndex(ItemDb.IMAGE));
          ImageView iv = (ImageView) v.findViewById(R.id.photo);
  
          if (image != null) {
              if (image.length &gt; 3) {
                  iv.setImageBitmap(BitmapFactory.decodeByteArray(image, 0,image.length));
              }
          }
  
          TextView tname = (TextView) v.findViewById(R.id.name);
          tname.setText(name);
          TextView tcondition = (TextView) v.findViewById(R.id.condition);
          tcondition.setText(condition);
          TextView temail = (TextView) v.findViewById(R.id.email);
          temail.setText(email);
  
  
  
          final ItemSQLiteConnector sqlCon = new ItemSQLiteConnector(context);
  
          editBtn=(ImageButton) v.findViewById(R.id.edit_btn);    
          editBtn.setOnClickListener(new View.OnClickListener() {
  
              @Override
              public void onClick(View v) {
                  Intent intent=new Intent(context, AddEditItem.class).setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);               
                  intent.putExtra("id", id);
                  intent.putExtra("user", user);
                  intent.putExtra("name", name);
                  intent.putExtra("condition", condition);
                  intent.putExtra("email", email);
                  intent.putExtra("category", category);
                  intent.putExtra("blob", image);
                  context.startActivity(intent);
              }
  
          });
  
          delBtn=(ImageButton) v.findViewById(R.id.del_btn);  
          delBtn.setOnClickListener(new View.OnClickListener() {
  
  
              @Override
              public void onClick(View v) {
                  sqlCon.deleteItem(id);      
                  //Cursor cur=db.query(ItemDb.TABLE, null, "_id="+ id, null, null, null,null);   
                  //myadapter.changeCursor(cur);
                  //myadapter.notifyDataSetChanged();
  
                  //Intent intent=new Intent(context,Tab.class).setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                  //context.startActivity(intent);        
              }
  
          });     
  
  
          v.setOnClickListener(new View.OnClickListener() {
  
              @Override
              public void onClick(View v) {
  
                  Intent intent=new Intent(context,ViewItem.class).setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);               
                  intent.putExtra("id", id);
                  intent.putExtra("user", user);
                  intent.putExtra("name", name);
                  intent.putExtra("condition", condition);
                  intent.putExtra("email", email);
                  intent.putExtra("category", category);
                  intent.putExtra("blob", image);
                  context.startActivity(intent);
              }
          });
  
      }
  
  }
  </code></pre>