I have a ListView that I am trying to update from a database after adding to the database.
While the data is into the List, and also getting into the ListView, the ListView isn't updating the number of items in the List.
So if my list was {1, 3, 6, 8, 12} After adding 4 to the List and sorting, my list view shows {1, 3, 4, 6 ,8} not showing the 6th item 12.
This problem compounds itself as I add more to the list, where if I were to add another item, this ListView would still only show the first 5.
Here is the code area having problems
TourGroup group = data.getParcelableExtra(TOURGROUP);
DatabaseHandler db = new DatabaseHandler(this);
db.addGroup(group);
mainList = db.getAllGroups();
db.close();
Collections.sort(mainList, new CustomComparator());
ListView groupList = (ListView) findViewById(R.id.groupList);
ArrayAdapter adapter = (ArrayAdapter) groupList.getAdapter();
adapter.notifyDataSetChanged();
If I replace
mainList = db.getAllGroups();
With
mainList.add(group);
then the ListView updates correctly. But this is not the solution I want, as this wouldn't be updating the List view from the database.
I've been banging my head on this problem for hours now, any help would be appreciated.