2016-02-16 12 views
8

- List<E> nasıl dönüştürebilirim? kopya getTitle() doğru sonuç verir nedenDönüştür RealmResults <E> kopyalamak için <E> copyFromRealm ile

RealmResults<EventRealm> result = realm.where(EventRealm.class).findAll(); 

EventRealm eventRealm = result.get(0); 
int id = eventRealm.getId(); // return id 2564 
String title = eventRealm.getTitle(); // return "My event" 

List<EventRealm> copied = realm.copyFromRealm(result); 

EventRealm eventRealm1 = copied.get(0); 
int id1 = eventRealm1.getId(); // return id 0 
String title1 = eventRealm1.getTitle(); // return "My event" 

Ama hemen değil anlıyorum, ama getId() yanlış:

Ben yöntemle copyFromRealm ile çalıştı.

Modeli

public class EventRealm extends RealmObject { 

     @PrimaryKey 
     private int id; 
     private String title; 

     public int getId() { 
      return id; 
     } 

     public void setId(int id) { 
      this.id = this.id; 
     } 

     public String getTitle() { 
      return title; 
     } 

     public void setTitle(String title) { 
      this.title = title; 
     } 
    } 

cevap

8

Sorun setId yöntemdir.

Artık o yapar:

public void setId(int id) { 
    this.id = this.id; 
} 

O

public void setId(int id) { 
    this.id = id; 
} 
+4

ben utanıyorum, ben, zaman üzgün harcanan am olduğumu olmalıdır – Alexandr

İlgili konular