I am using Room to manage SQLite databasae in my app. The thing is that I am migrating a project, in which I download some data from a private webservice and finally I am receiving a ContentValues object which contains all the data to save to my POJO (let's say UserPojo). Because I have this ContentValues object, I initially thought in using the SqLiteOpenHelper's insert method, but I do not know how to get an instance of it from my RoomDatabase, neither whether it is a good practice to implement, neither how to alternatively do it...
What I tried was the following:
MyDatabase.getDatabaseInstance(MyApplication.getAppContext()).getOpenHelper().getWritableDatabase().insert(currentTable, CONFLICT_NONE, rowValues);
Is it okey? Where should I call it from? ViewModel? A new DAO? How shall I do it?
Thanks.
If you are inserting into Room, then you would have an Entity which is really a normal class with annotations so that Room can create and access the table.
As such you could create an instance(s) of the class/entity from the ContentValues (using the appropriate get methods) and then use Room to insert(s) (@Insert).