Created
August 10, 2018 06:45
-
-
Save KanshuYokoo/0717fd01a9c5d73a3b0af2e5b595d5fb to your computer and use it in GitHub Desktop.
realm for android java save gist
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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