Android ExpandableListView with SimpleCursorTreeAdapter not refreshing
<p>I'm new to this ExpandableListView and I desperately need your help please.</p>

<p>I'm using the code below to create an ExpandableListView with SimpleCursorTreeAdapter because I'm geting my data from SQLite database.
It all works fine, but I can't find a solution on how to add some items to the parent ListView (for now).
I'd like to add a category with a click on a TextView.</p>

<pre><code>public class ListViewExp extends ExpandableListActivity {
    private DBAdapter db;
    private Cursor  getMatchigItems;
    private Cursor getAllCat;
    private ExpandableListView expListView;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.testexpview);
        TextView tv1 = (TextView) findViewById(R.id.testtext);
        db = new DBAdapter(this);
        db.open();
        getAllCat = db.getAllCategories(1);
        startManagingCursor(getAllCat);

        final SimpleCursorTreeAdapter cursorTreeAdapter = new SimpleCursorTreeAdapter(
                getApplicationContext(),
                getAllCat,
                R.layout.group_row,
                R.layout.group_row,
                new String[]{db.KEYCAT_TXTCATEGORYNAME, db.KEYCAT_ROWID},
                new int[]{R.id.groupname},
                R.layout.child_row,
                R.layout.child_row,
                new String[]{db.KEYITEMS_TXTITEMNAME, db.KEYITEMS_ROWID, db.KEYITEMS_ROWID},
                new int[]{R.id.childname,R.id.rgb}) {

            @Override
            protected Cursor getChildrenCursor(Cursor groupCursor) {
                db.open();
                getMatchigItems = db.getMatchingItems(groupCursor.getLong(0), 1);
                startManagingCursor(getMatchigItems);
                return getMatchigItems;
            }
        };
        expListView = getExpandableListView();
        setListAdapter(cursorTreeAdapter);

        tv1.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                db.open();
                db.addMyCategory("TestCat1", "");
//              getAllCat.requery();
                cursorTreeAdapter.notifyDataSetChanged();
            }
        });
        db.close();
    }
}
</code></pre>

<p>Adding to the database works fine, but I see the new item only when restarting my app.
I have tryed to requery the cursor getAllCat.requery(); , but when I do that it refreshes the list but it's empty (not even older item are displayed) like there is no data.</p>

<p>Can anyone please give me some guidance on how to resolve this?
Am I missing something?</p>

<p>Should I do the onResume override or should I do this completely different?
Thanks a million in advance!
Best regards!</p>
