Advertisement
Guest User

Untitled

a guest
Sep 25th, 2016
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. private String writeToRealm(WeatherResponse weatherResponse) {
  2. Realm realm = Realm.getDefaultInstance();
  3. realm.executeTransaction(transactionRealm -> {
  4. WeatherRealm weatherRealm = findInRealm(transactionRealm, weatherResponse.getName());
  5. if (weatherRealm == null)
  6. weatherRealm = transactionRealm.createObject(WeatherRealm.class, weatherResponse.getName());
  7. weatherRealm.setTemp(weatherResponse.getMain().getTemp());
  8. });
  9. realm.close();
  10. return weatherResponse.getName();
  11. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement