Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Map<String, Integer> mapalimentos = new HashMap<>();
- mapalimentos.put("Maçã",60);
- mapalimentos.put("Melancia",75);
- mapalimentos.put("Banana",45);
- //Log.d(TAG, "addalimentosbanco: adicionou");
- for (final Map.Entry<String,Integer> entry : mapalimentos.entrySet()) {
- //Log.d(TAG, "addalimentosbanco: Nome: " + entry.getKey() +" Calorias: "+ entry.getValue());
- realm.executeTransaction(new Realm.Transaction() {
- @Override
- public void execute(Realm realm) {
- Alimento alimento = realm.createObject(Alimento.class);
- alimento.setNome(entry.getKey());
- alimento.setCalorias(entry.getValue());
- }
- });
- }
- RealmResults<Alimento> results = realm.where(Alimento.class).findAll();
- Log.d(TAG, "addalimentosbanco: Result: " + results);
Add Comment
Please, Sign In to add comment