title: android changeCursor() not taking effect
body: <p>I am learning android programming and I am writing a small SQL to list app to get "comments" out of DB and put them on a list using a custom CursorAdapter. It all seems to be functional BUT on add/delete the list doesn't repopulate  (delete seems to not function at all). I am calling changeCursor() but it does not appear as though my list updates. After a fresh run I can see the results of the previous run. Any help is greatly appreciated.
  Here is my code:</p>
  
  <p>CommentsDataSource.java:</p>
  
  <pre><code>import android.content.ContentValues;
  import android.content.Context;
  import android.database.Cursor;
  import android.database.SQLException;
  import android.database.sqlite.SQLiteDatabase;
  
  import java.util.ArrayList;
  import java.util.List;
  
  public class CommentsDataSource {
  
  private MySQLiteHelper SQLhelper;
  private SQLiteDatabase database;
  
  public CommentsDataSource (Context context) {
      // Create a link to database:
      SQLhelper = new MySQLiteHelper(context);
  }
  
  public void open() throws SQLException {
      database = SQLhelper.getWritableDatabase();
  }
  public void close () {
      database.close();
  }
  
  public Comment createComment (String comment) {
      ContentValues values = new ContentValues();
      values.put(MySQLiteHelper.COLUMN_COMMENT, comment);
  
      long id = database.insert(MySQLiteHelper.TABLE_COMMENTS, null, values);
      Cursor cursor = database.rawQuery("SELECT * FROM " + MySQLiteHelper.TABLE_COMMENTS + " WHERE " + MySQLiteHelper.COLUMN_ID + " = " + id, null);
  
      cursor.moveToFirst();
      Comment newComment  = new Comment();
      newComment.setId(cursor.getLong(0));
      newComment.setComment(cursor.getString(1));
  
      cursor.close();
      return newComment;
  }
  
  public void deleteComment (Comment comment) {
      long id = comment.getId();
      System.out.println("Comment deleted with id: " + id);
      database.delete(MySQLiteHelper.TABLE_COMMENTS, MySQLiteHelper.COLUMN_ID
              + " = " + id, null);
  
  }
  
  public List&lt;Comment&gt; getAllComments () {
      List&lt;Comment&gt; list = new ArrayList&lt;&gt;();
      Cursor cursor = database.rawQuery("SELECT * FROM " + MySQLiteHelper.TABLE_COMMENTS, null);
      cursor.moveToFirst();
  
      Comment newComment  = new Comment();
  
      while (! cursor.isAfterLast()) {
          newComment.setId(cursor.getLong(0));
          newComment.setComment(cursor.getString(1));
          list.add(newComment);
          cursor.moveToNext();
      }
  
      cursor.close();
      return list;
  }
  
  public Cursor getCursor() {
      List&lt;Comment&gt; list = new ArrayList&lt;&gt;();
      Cursor cursor = database.rawQuery("SELECT * FROM " + MySQLiteHelper.TABLE_COMMENTS, null);
      return cursor;
  }
  }
  </code></pre>
  
  <p>MainActivity:</p>
  
  <pre><code>public class MainActivity extends ListActivity {
  
  private CommentsDataSource dataSource;
  private Context context;
  
  @Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
      this.context= this;
  
      dataSource = new CommentsDataSource(this);
      dataSource.open();
  
      List&lt;Comment&gt; values = dataSource.getAllComments();
  
      /*ArrayAdapter&lt;Comment&gt; adapter = new ArrayAdapter&lt;Comment&gt;(this, android.R.layout.simple_expandable_list_item_1, values);
      setListAdapter(adapter);*/
  
      Cursor cursor = dataSource.getCursor();
      ListView lvItems = (ListView) findViewById(android.R.id.list);
  
      CustomCursorAdapter adapter = new CustomCursorAdapter(this, cursor);
      lvItems.setAdapter(adapter);
  
  
  }
  public void onClick(View view) {
      @SuppressWarnings("unchecked")
      Cursor cursor = dataSource.getCursor();
  
      CustomCursorAdapter adapter = new CustomCursorAdapter(context, cursor);
      Comment comment = null;
      switch (view.getId()) {
          case R.id.add:
              String[] comments = new String[] { "Cool", "Very nice", "Hate it" };
              int nextInt = new Random().nextInt(3);
              // save the new comment to the database
              comment = dataSource.createComment(comments[nextInt]);
              break;
          case R.id.delete:
              if (adapter.getCount() &gt; 0) {
                  Cursor d = (Cursor) adapter.getItem(0);
                  comment = new Comment();
                  comment.setComment(d.getColumnName(1));
  
                  dataSource.deleteComment(comment);
              }
              break;
      }
  
      Cursor newcursor = dataSource.getCursor();
      adapter.changeCursor(newcursor);
  
  }
  
  }
  </code></pre>
  
  <p>customCursorAdapter:</p>
  
  <pre><code>public class CustomCursorAdapter extends CursorAdapter {
  public CustomCursorAdapter(Context context, Cursor c) {
      super(context, c, 0);
  }
  
  @Override
  public View newView(Context context, Cursor cursor, ViewGroup parent) {
      return LayoutInflater.from(context).inflate(R.layout.list_item, parent, false);
  }
  
  @Override
  public void bindView(View view, Context context, Cursor cursor) {
      TextView type = (TextView) view.findViewById(R.id.setType_textView);
      TextView name = (TextView) view.findViewById(R.id.exerciseName_textView);
  
      name.setText(cursor.getString(1));
  }
  }
  </code></pre>