android - How to create private RealmObjects in a shared Realm -
my goal pretty simple: need create private realmobjects
in shared realm
.
i created objects , stored them in shared realm
. give users ability store objects privately though. far know have 2 ways accomplish this, none of them working.
solution 1: using permissions let users
share realm objects each other in following sample:
public static void setactiveuser(final syncuser user) { if (user.isvalid()) { syncconfiguration defaultconfig = new syncconfiguration.builder(user, colombo.server_url).build(); realm.setdefaultconfiguration(defaultconfig); realm realm = user.getmanagementrealm(); realm.executetransaction(new realm.transaction() { @override public void execute(realm realm) { string includeall = "*"; change = new permissionchange(includeall, includeall, true, true, false); realm.insert(change); } }); } }
unfortunately doesn't work, synchronized realms
visibile current syncuser
.
solution 2: create "common" syncuser
save/show public items , private syncuser
each registered user collect private items, switching common private syncuser
depending on needs. anyway seems quite inefficient me. how sound you? think there's way can it?
you cannot use realm's authentication mechanism provide different login permissions different accounts single realm.
as nabil said, can programmatically control access assigning uuids users, , querying them per user.
Comments
Post a Comment