java - New SimpleCursorAdapter whenever data changes? -
java - New SimpleCursorAdapter whenever data changes? -
i'm starting out android development , have been building simple app uses listactivity, sqlitedatabase, , simplecursoradapter.
on android developer website there illustration project demonstrates usage of simplecursoradadpter. looking @ implementation, whenever underlying database modified result of user action, listactivity explicitly calls next function "refresh" list:
private void filldata() { // of rows database , create item list mnotescursor = mdbhelper.fetchallnotes(); startmanagingcursor(mnotescursor); // create array specify fields want display in list (only title) string[] = new string[]{notesdbadapter.key_title}; // , array of fields want bind fields (in case text1) int[] = new int[]{r.id.text1}; // create simple cursor adapter , set display simplecursoradapter notes = new simplecursoradapter(this, r.layout.notes_row, mnotescursor, from, to); setlistadapter(notes); } it looks new simplecursoradapter created every time , bound view setlistadapter(). best/cleanest implementation? fact on android website lends lot of credibility, looked @ cursoradapter documentation , saw there changecursor() method seems lend cleaner implementation 1 above, i'm not sure might like.
maybe i'm fretting on nothing, coming c/c++ world, , seeing "new" object created each time insert/delete row database seems bit heavy-handed.
yes, right. can see lot of times. little lists may not produce problems when list created in onresume. that's no style. can utilize cursor.changecursor() or adapter.notifydatasetchanged().
java android simplecursoradapter
Comments
Post a Comment