Created
January 20, 2017 01:28
-
-
Save vinpac/49e5f580339b184fdc87c365b51781c3 to your computer and use it in GitHub Desktop.
Realm example
This file contains 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
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