In my application I create an ArrayList that is holding my calendar event objects (WeekViewEvents) with different fields (mostly Strings and int's):
ArrayList<WeekViewEvent> mNewEvents = new ArrayList<>;
...
WeekViewEvent event = new WeekViewEvent();
event.setName("abc");
event.setId(123);
mNewEvents.add(event);
And that Array (in its form) is directly used by Calendar Library Now, I want to save and read the list in internal memory using Room Persistence Library. The thing is that I'm not sure:
if I will be able to load my ArrayList and use it the same way I do now even if it needs @TypeConverter?
can I write my @Entity class like below: ?
@Entity public class Events {
@NonNull @PrimaryKey public ArrayList mNewEventsRPL;
public ArrayList getEvents() { return mNewEventsRPL; }
public void setEvents(ArrayList evenciki) { this.mNewEventsRPL=evenciki; }}
I've converted single event object to String using GSON and it looks like this:
{"mAllDay":false,"mColor":-6454059,"mEndTime":{"year":2018,"month":0,"dayOfMonth":30,"hourOfDay":16,"minute":46,"second":35},"mId":"111222333","mLocation":"klient","mName":"usluga","mStartTime":{"year":2018,"month":0,"dayOfMonth":30,"hourOfDay":15,"minute":46,"second":35}}
So now the question is: how should I write my @TypeConverter so it can save&load my ArrayList?