Realm Taking Too Long To Copy Objects To Realmobject
I'm using realm to store a list of Products in my Andorid App. So, I receive a produtc's list with about 3k objects. And I'm trying to store them like this: @Override public void
Solution 1:
It will be faster if you can add the objects to your Realm in fromDomainToPersistence()
. The saveAll()
method could be something like:
publicvoidsaveAll(...) {
Realminstance= getRealmInstance();
try {
instance.beginTransaction();
for (ProductsDomain domainProduct : domainProducts) {
fromDomainToPersistence(instance, domainProduct);
}
instance.commitTransaction();
} catch (Exception e) {
// ...
}
}
and
publicvoidfromDomainToPersistence(Realm r, DomainProduct domainProduct){
ProductRealm realmProduct = r.createObject(ProductRealm.class);
// set the fields' values
}
Post a Comment for "Realm Taking Too Long To Copy Objects To Realmobject"