I have a pre-initialized .realm file that I'm trying to access in Android Studio. I have used Realm browser to figure out the exact schema to model my classes after (i.e. field names and types), but I can't figure out what the Any
type of the comments
field (see screenshot below) should be in my code.
According to this, the field can only be a boolean
, short
, ìnt
, long
, float
, double
, String
, Date
, byte[]
, subclasses of RealmObject
, or RealmList<? extends RealmObject>
. I've tried a bunch of different types for the comments
field, but I continue to get errors similar to the following:
io.realm.exceptions.RealmMigrationNeededException: Invalid type 'String' for field 'comments'
When I try to allow comments
to be as generic as possible by making its type RealmObject
, my code fails to even compile successfully:
/Users/name/AndroidStudioProjects/Project/app/build/intermediates/classes/debug/io/realm/ReportRealmProxy.java
Error:(147, 17) error: cannot find symbol variable RealmObjectRealmProxy
Error:(285, 48) error: cannot find symbol variable RealmObjectRealmProxy
Error:(330, 52) error: cannot find symbol variable RealmObjectRealmProxy
Error:(374, 41) error: cannot find symbol variable RealmObjectRealmProxy
Error:(420, 41) error: cannot find symbol variable RealmObjectRealmProxy
Finally, when I tried to use Realm Browser's automatic model code generation (File -> Save Model Definitions -> Save Java definitions...), the following code is produced:
import io.realm.RealmObject
public class Report extends RealmObject {
private String term;
private String year;
private int enrollment;
private Any comments;
private RealmList<Response> responses;
private RealmList<FacultyReport> facultyReports;
}
Unfortunately, neither Android Studio nor I understand what the Any
class is - I can't find any mention of it online.
Any help would be much appreciated, as I am unable to load the data without exactly matching the model definitions used to create it. If there were a way to load all the data except the Report class/table, that would work too, because it is currently empty (as the screenshot shows). But, currently, even though it is empty, my inability to model it is preventing me from loading any objects at all!
Edit: Here is my Report.java
class code:
import io.realm.RealmList;
import io.realm.RealmObject;
public class Report extends RealmObject {
private String term;
private String year;
private int enrollment;
private ???? comments;
private RealmList<Response> responses;
private RealmList<FacultyReport> facultyReports;
public ???? getComments() {
return comments;
}
public void setComments(???? comments) {
this.comments = comments;
}
// other getters and setters removed
}