Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Save an object in the Realm database
public class University extends RealmObject {
@Index
private int id;
private String name;
// Standard getters & setters generated by your IDE…
}
Realm realm = Realm.getInstance(this);
realm.beginTransaction();
University university = realm.createObject(University.class); // Create a new object
user.setName("John");
realm.commitTransaction();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment