Java POJO Object
public class Section {
@ColumnInfo(name=\"section_id\")
public int mSectionId;
@ColumnInfo(name=\"section_name\")
public S
I would suggest to create another query without LiveData if you need to synchronously fetch data from database in your code.
DAO:
@Query("SELECT COUNT(*) FROM section")
int countAllSections();
ViewModel:
Integer countAllSections() {
return new CountAllSectionsTask().execute().get();
}
private static class CountAllSectionsTask extends AsyncTask {
@Override
protected Integer doInBackground(Void... notes) {
return mDb.sectionDAO().countAllSections();
}
}