My main screen is a list of names queried from database ,which on click gives certain information about the name(Phone number,Hierarchy, mail id etc).I also have options to edit and add new contact(I have added buttons to do so ). Everything works fine , but , I cannot see the names immediately when I update the names into database. But when I rerun the application , I can see the changes . How do I display the names dynamically and efficiently?
One thing I can think is query the database again , onResume and display.But I don’t feel it is efficient enough.
Also I could use startActivityforResult() but I cant arrange them in ascending order and I upload many contacts at a time.
CODE
// Make a New Database
DBContact info = new DBContact(this);
info.open();
String[] data = info.queryAll();
info.close();
// Display the names
ArrayAdapter<String> adapter = new ArrayAdapter<String>(Contacts.this,
android.R.layout.simple_list_item_1, data);
listview.setAdapter(adapter);
Have a look at notifyDataSetChanged() in the docs. When you have added data to the database, call this to update the list.