Skip to content

Instantly share code, notes, and snippets.

@KanshuYokoo
Created August 10, 2018 06:45
Show Gist options
  • Save KanshuYokoo/0717fd01a9c5d73a3b0af2e5b595d5fb to your computer and use it in GitHub Desktop.
Save KanshuYokoo/0717fd01a9c5d73a3b0af2e5b595d5fb to your computer and use it in GitHub Desktop.
realm for android java save gist
private <E extends RealmModel> E saveToRealm(E model) {
E result_model;
try {
Realm realm = Realm.getDefaultInstance();
realm.beginTransaction();
result_model = realm.copyToRealmOrUpdate(model);
realm.commitTransaction();
realm.close();
} catch (RealmException ex) {
throw ex;
}
return result_model;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment