Retrofit2 response
*@Override
public void onResponse(Call<List<Category>> call, final Response<List<Category>> response) {
switch (response.code()) {
case 200:
if (response.body() != null && !response.body().isEmpty()) {
final List<Category> categoryList = response.body();
Realm.getDefaultInstance().executeTransactionAsync(new Realm.Transaction() {
@Override
public void execute(Realm realm) {
for (Category category : categoryList) {
realm.insertOrUpdate(category);
}
}
});
}
RealmObjects
public class Category extends RealmObject {
private String catName;
@PrimaryKey
private int catId;
private RealmList<ChannelList> channelList;
public String getCatName() {
return catName;
}
public void setCatName(String catName) {
this.catName = catName;
}
public int getCatId() {
return catId;
}
public void setCatId(int catId) {
this.catId = catId;
}
public RealmList<ChannelList> getChannelList() {
return channelList;
}
public void setChannelList(RealmList<ChannelList> channelList) {
this.channelList = channelList;
}
}
public class ChannelList extends RealmObject {
private String channelName;
private String outputUrl;
@PrimaryKey
private int channelId;
private String thumbnail;
public ChannelList() {
}
public ChannelList(String channelName, String outputUrl, String thumbnail, int channelId) {
this.channelName = channelName;
this.outputUrl = outputUrl;
this.thumbnail = thumbnail;
this.channelId = channelId;
}
public String getChannelName() {
return channelName;
}
public void setChannelName(String channelName) {
this.channelName = channelName;
}
public String getOutputUrl() {
return outputUrl;
}
public void setOutputUrl(String outputUrl) {
this.outputUrl = outputUrl;
}
public int getChannelId() {
return channelId;
}
public void setChannelId(int channelId) {
this.channelId = channelId;
}
public String getThumbnail() {
return thumbnail;
}
public void setThumbnail(String thumbnail) {
this.thumbnail = thumbnail;
}
}
This setup is working fine in debug build, but when I generate release build, this causes error
field Catagory.channeList has type RealmList got ArrayList
Don't know why its working in debug build. I have gone through some solutions but no luck in my case. Any help would be appreciated, thanks
Finally found the solution using.
and