android - Using AsyncTask to read items from a database -


i decided add asynctask fragment in app in order receive items database more efficiently.

i set generics void, void, list<object> (where object object created), , inner methods follows:

private class getobjectstask extends asynctask<void, void, list<object>> {      @override     protected list<object> doinbackground(void... params) {         sqlitedatabase db = mdbhelper.getinstance(getactivity().getapplicationcontext()).getreadabledatabase();          string[] projection = {                 .........         };          string sortorder = ...;          cursor c = db.query(table_name, projection, null, null, null, null, sortorder);          while(c.movetonext()) {             long itemid = ...;             string title = ...;             long startmil = ...;             long endmil = ...;              mlist.add(new object(itemid, title, new date(startmil), new date(endmil), null, null));         }          db.close();         return mlist;     } } 

and here how call task same fragment:
new getobjectstask().execute((void[]) null);

after execution of task, set list view show items array.
exact same code used before without task should work. problem - doesn't. mlist defined in fragment holding inner task class, expected work.

what cause such behavior?
also, possible (and recommanded) make task set list view show returned items well? (by overriding onpostexecute(result))

thank you!

onpostexecute(result) place should initialize listview , set adapter. cause onpostexecute() running in main ui thread.


Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

Function that returns a formatted array in VBA -