i've got this class:
public class ProfileData extends SugarRecord {
@Expose
public Data data;
public ProfileData(Data data) {
this.data = data;
}
public static class Data {
public long id;
@Expose
public String email;
@Expose
public String name;
@Expose
public String surname;
@Expose
public String address;
@Expose
public String city;
@Expose
public long pesel;
@Expose
public long phone;
@Expose
public long userId;
@Expose
public long clubId;
@Expose
public String fullName;
@Expose
public long clientStatusId;
@Expose
public String provider;
@Expose
public String uid;
@Expose
public boolean gender;
public Data(long id, String email, String name, String surname, String address, String city,
long pesel, long phone, long userId, long clubId, String fullName,
long clientStatusId, String provider, String uid, boolean gender) {
this.id = id;
this.email = email;
this.name = name;
this.surname = surname;
this.address = address;
this.city = city;
this.pesel = pesel;
this.phone = phone;
this.userId = userId;
this.clubId = clubId;
this.fullName = fullName;
this.clientStatusId = clientStatusId;
this.provider = provider;
this.uid = uid;
this.gender = gender;
}
}
I populate this class with data from JSON (with Gson). Then i call save() method ('data' object is an instance of ProfileData):
data.save();
My next step is:
List<ProfileData> profileList = ProfileData.listAll(ProfileData.class);
And profileList is empty.
I put this lines into AndroidManifest:
<meta-data
android:name="DATABASE"
android:value="sugar_example_my.db" />
<meta-data
android:name="VERSION"
android:value="2" />
<meta-data
android:name="QUERY_LOG"
android:value="true" />
<meta-data
android:name="DOMAIN_PACKAGE_NAME"
android:value="com.example.my" />
And finally in my App class i put this line:
SugarContext.init(this);
Any suggetions?
EDIT:
I solved this by adding public Data() {} into Data class and moving
extends SugarRecord
from ProfileData to Data.
I think the trouble is that your list should be List<Data>