2016-06-19 10 views

Antwort

0

Realm bietet eine Möglichkeit, von überall auf Ihre Instanz zuzugreifen.

// Create a RealmConfiguration that saves the Realm file in the app's "files" directory. 
//(Recommended to add this code in your Application or first Activity) 
RealmConfiguration realmConfig = new RealmConfiguration.Builder(context).build(); 
Realm.setDefaultConfiguration(realmConfig); 

//then call it from your service 
Realm realm = Realm.getInstance(this); 

//access your realm object 
realm.beginTransaction(); 
final Dog managedDog = realm.copyToRealm(dog); // Persist unmanaged objects 
Person person = realm.createObject(Person.class); // Create managed objects directly 
person.getDogs().add(managedDog); 
realm.commitTransaction(); 

see docs

+0

Thank you so viel es funktioniert hat. –

+0

Kein Problem, großartig! – diogojme

Verwandte Themen