title: How do I refresh my ListView after the database changes?
body: <p>I am trying to manage a simple list in an Android application. The contents of the list are maintained in a SQLite database. When the user selects and holds on a specific row, a context menu appears with a "Delete" option. When they select "Delete", the row is deleted from the database, but the view does not refresh. When I back out of the application and get back in, the appropriate row has been removed. So, I know the row is deleted, it's just the ListView that doesn't refresh.</p>
  
  <p>Here are the relevant bits of code...</p>
  
  <p>In the onCreate method...</p>
  
  <pre><code>SQLiteDatabase db = tasks.getReadableDatabase();
  Cursor cursor = db.query(TABLE_NAME, 
      new String[] { _ID, TITLE, DETAILS, }, 
      null, null, null, null, TITLE + " DESC");
  startManagingCursor(cursor);
  
  ListView lv = (ListView) findViewById(R.id.list);
  lv.setAdapter(new SimpleCursorAdapter(this, 
      android.R.layout.simple_list_item_1,
      cursor,
      new String[] {TITLE},
      new int[] { android.R.id.text1}
  ));
  </code></pre>
  
  <p>In the onContextItemSelected method...</p>
  
  <pre><code>switch(item.getItemId()) {
  case 0:
      SQLiteDatabase db = tasks.getWritableDatabase();
      ListView lv = (ListView) findViewById(R.id.list);
      SimpleCursorAdapter adapter = (SimpleCursorAdapter) lv.getAdapter();
      db.delete(TABLE_NAME, "_ID=?", new String[] {adapter.getCursor().getString(0)});
      adapter.notifyDataSetChanged(); // Not working, clears screen and doesn't reload
      return true;
  }
  return super.onContextItemSelected(item);
  </code></pre>
  
  <p>What am I missing?</p>
  
  <p>Thanks!</p>