Java POJO Object
public class Section {
@ColumnInfo(name=\"section_id\")
public int mSectionId;
@ColumnInfo(name=\"section_name\")
public S
if sections.getValue() is null I have to call api for data and insert in into the database
You can handle this at onChange
method:
sections.observe(this, new Observer>() {
@Override
public void onChanged(@Nullable List sections){
if(sections == null || sections.size() == 0) {
// No data in your database, call your api for data
} else {
// One or more items retrieved, no need to call your api for data.
}
}
});
But you should better put this Database/Table initialization logic to a repository class. Check out Google's sample. See DatabaseCreator class.