lundi 6 avril 2015

database operation in android loader

I'm using a LoaderManager, the onCreateLoader method creates a new CursorLoader.



@Override
public Loader<Cursor> onCreateLoader(int id, Bundle data) {
return new CursorLoader(context, CONTENT_URI, PROJECTION,
null, null, null);
}


Only after loading is finished in onLoadFinished() the UI is updated. Every time I load the cusor I also need to do some database manipulation like building up a new sort index. This cannot be done asynchronously because the UI depends on this.


Is there a way to do such db operation within the loader? Or what is the best design for this problem?


Aucun commentaire:

Enregistrer un commentaire