Why isn't my ListView updating when I call notifyDataSetChanged()?
<p>I'm close to finishing my first Android app, but I'm fighting with an odd bug when I delete items from the SQLite DB that feeds a ListView in my app. The item gets deleted, and if I switch away from the ListView and back, it updates, but until I do that, the list doesn't update.</p>

<p>I've posted most of the class in question here: <a href="https://gist.github.com/2025973" rel="nofollow">https://gist.github.com/2025973</a>, but here's the relevant callback starting at line 56 in the file:</p>

<pre><code>builder.setPositiveButton(R.string.button_delete,
    new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            databaseConnector.deleteSimpleDie(arg3);
            storedDiceAdapter.notifyDataSetChanged();
        }
    });
</code></pre>

<p>What am I doing wrong here? I'm sure it's something simple. I originally had the delete in an Async, but then I couldn't call the notifyDataSetChanged() at all, because it has to happen from the thread that created the Cursor.</p>

<p><strong>UPDATE</strong></p>

<p>Okay, this is pretty ghetto ( I think... ) but I've got it working, finally. Someone want to tell me how horribly wrong this is? Basically, I'm just re-instantiating the whole CursorAdapter inside the callback. It solves the problem, but I suspect it has some negative side effects I'm not aware of.</p>

<pre><code>builder.setPositiveButton(R.string.button_delete,
    new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            databaseConnector.deleteSimpleDie(arg3);

            String[] from = new String[] { "name", "description" };
            int[] to = new int[] { R.id.dice_name, R.id.dice_description };

            storedDiceAdapter = new SimpleCursorAdapter(StoredDice.this,
                    R.layout.stored_dice_item, null, from, to);
                setListAdapter(storedDiceAdapter);
        }
    });
</code></pre>
