Android -room Persistent Library - DAO Calls Are Async, Therefore How To Get Callback?
Answer : If you want to do your query synchronously and not receive notifications of updates on the dataset, just don't wrap you return value in a LiveData object. Check out the sample code from Google. Take a look at loadProductSync() here There is a way to turn off async and allow synchronous access. when building the database you can use :allowMainThreadQueries() and for in memory use: Room.inMemoryDatabaseBuilder() Although its not recommended. So in the end i can use a in memory database and main thread access if i wanted super fast access. i guess it depends how big my data is and in this case is very small. but if you did want to use a callback.... using rxJava here is one i made for a list of countries i wanted to store in a database: public Observable<CountryModel> queryCountryInfoFor(final String isoCode) { return Observable.fromCallable(new Callable<CountryModel>() { @Override public CountryModel call() throws Exception { ...