I am making an application where I have to persist data in a database, I have one single table in my project with multiple entity classes. Actually, I have to take some values from each POJO classes and have to store in a single table in the database. I have a class which has some following fields
private List<CurrentWeatherInfoDBModel> currentWeatherInfoDBModel =
new ArrayList<CurrentWeatherInfoDBModel>();
private CurrentWeatherMainDBModel currentWeatherMainDBModel;
private CurrentWeatherWindDBModel currentWeatherWindDBModel;
private CurrentWeatherCloudsDBModel currentWeatherCloudsDBModel;
private long dt;
private CurrentWeatherSysDBModel currentWeatherSysDBModel;
private int id;
private String name;`
now say for example CurrentWeatherMainDBModel is a pojo class containing 2 another fields that has to be stored into that single table. I am using Room as my database. How can I do that?
Extract all data you need to insert into database from their sources into one POJO and make this newly created POJO your entity for ROOM. So, if you need to get any data from your database, you will refer to this newly created POJO since that will be the building block of your database
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.