问题
I am following the MVVM Model. I would like to have Real-time data from SQLite database through Room (Results shall available as soon as data changes in Database). With LiveData, we can get results in Activity/Fragment. Callback also won't good on this type of requirement since data should be pushed from the database. Is there any way I can get in any class outside of activity/fragment?.
Thanx in advance for your help.
EDIT
Putting sample code for better understanding..Is there a way to observe Room database Table so that we always have latest data from table?
Filter filter = mCustomerFilterDao.fetchcustomerSettings(settings);
// Want to add observe for filter table so that we have latest customer
//settings. This is my Query.
List<Book> booklist = new ArrayList<>();
for(Book book:bookrecords)
{
if(book.status == filter.status)
{booklist.add(book);}
}
来源:https://stackoverflow.com/questions/53830522/real-time-data-from-sqlite-database-through-room-outside-activity-fragment-follo