Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android: How to use greenDao for async loading data?

I would like use greenDao with a loader <cursor> to load asynchronously my data from the DB. I found example using loader with a contentProvider. I know that loaders are the best way to load data from a database because it handle the lifecycle of the cursor, auto update the cursor when we add a value.. Unfortunately there is no example of loader with greenDao, is it possible or I have to use a contentProvider??

Thx

like image 533
FlavienBert Avatar asked Nov 10 '22 13:11

FlavienBert


1 Answers

I came across this question since i was also have the same question, but I have an idea but have never tried it yet but you can maybe execute it faster and better than me. I think eventbus(https://github.com/greenrobot/EventBus) can be a solution, whenever there is a change in the local database (add,delete,update) you can notify an event, and in your activity you should have an event listener that will trigger content reload(re-query again) upon receiving the event.

like image 56
Edward Baylon Avatar answered Nov 14 '22 23:11

Edward Baylon