Skip to content

Instantly share code, notes, and snippets.

@vinpac
Created January 20, 2017 01:28
Show Gist options
  • Save vinpac/49e5f580339b184fdc87c365b51781c3 to your computer and use it in GitHub Desktop.
Save vinpac/49e5f580339b184fdc87c365b51781c3 to your computer and use it in GitHub Desktop.
Realm example
class User {
@PrimaryKey
private String id;
private String name;
private String avatar; // url do avatar
}
User user = new User("id", "Geovani", "https://68.media.tumblr.com/60c074d952ce220d58da51f9f99c4a58/tumblr_ojxrmvaMhN1qz7t0xo1_540.jpg");
Realm.init(context);
// Get a Realm instance for this thread
Realm realm = Realm.getDefaultInstance();
realm.beginTransaction();
realm.copyToRealm(user);
realm.commitTransaction();
ImageView mImageView = findViewById(r.id.image_view);
// Pra mostrar a imagem
Picasso picasso = Picasso.with(context);
picasso.setIndicatorsEnabled(false);
picasso.load(user.getAvatar())
.into(mImageView);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment