i have trouble, need event/callback when try write database. added greendao lib project, , able write/delete in db. no idea how callback after operation under db.
in introduction lib read "asyncoperationlistener asynchronous callback when operations complete". used tutorial: http://blog.surecase.eu/using-greendao-with-android-studio-ide/
can me trouble?
upd:
ok here added list in storage
getmyobjectdao().getsession().startasyncsession().insertorreplaceintx(myobject.class, list);
error here
list<myobject> items = getboxdao(c).getsession().startasyncsession().loadall(myobject.class);
how can asynchronously load data db?
is correct solution?
@override public void onasyncoperationcompleted(asyncoperation operation) { string operationis = null; switch (operation.gettype()) { case loadall: itemslist = boxrepository.getallboxes(getapplicationcontext());
by default operations performed synchronously, eliminating need callback. recent version of greendao
introduces asyncsession
, can used perform operations asynchronously , provides way set listener on it. see example below:
asyncsession asyncsession = app.getinstance().daosession.startasyncsession(); asyncsession.setlistener( new asyncoperationlistener() { @override public void onasyncoperationcompleted(asyncoperation operation) { // whats needed } }); asyncsession.insert(myobject);
simple ask if unclear!
Comments
Post a Comment