realm

Realm.io [Java] notifications - How to listen for changes only in certain Table?

别等时光非礼了梦想. 提交于 2019-12-04 06:36:46
I see this example code in realm java documentation. public class MyActivity extends Activity { private Realm realm; // A reference to RealmChangeListener needs to be held to avoid being // removed by the garbage collector. private RealmChangeListener realmListener; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); realm = Realm.getDefaultInstance(); reamlListener = new RealmChangeListener() { @Override public void onChange() { // ... do something with the updates (UI, etc.) ... }}; realm.addChangeListener(realmListener); } @Override protected

How to make a RealmList parcelable

南笙酒味 提交于 2019-12-04 06:26:32
i need to implement the Parcelable interface in a Realm model but i have no idea how to write a RealmList in a Parcel here is my code: public class SomeModel extends RealmObject implements Parcelable { public long id; public RealmList<SomeOtherModel> otherModels; protected SomeModel(Parcel in) { id = in.readLong(); //here i need to otherModel RealmList from parcel } @Override public void writeToParcel(Parcel dest, int flags) { dest.writeLong(id); // here i need to write the otherModels RealmList } //other methods omitted } pd: the SomeOtherModel class also implements the Parcelable interface

Realm database decryption failed

老子叫甜甜 提交于 2019-12-04 06:14:37
问题 Question : When I try to open encrypted realm file in Realm Browser (windows) and it gives me following message. Either this is not a Realm file or it's encrypted. Enter: 128-character hex-encoded encryption key Important - I am closing my realm before saving on disk. Code RealmConfiguration config = new RealmConfiguration.Builder() .name("w5uyqFyEDEK_OCWyl4123aa77") .schemaVersion(2) .encryptionKey(myClassObject.getRealmKey()) .deleteRealmIfMigrationNeeded() .build(); Methods public byte[]

Realm gradle tasks

倾然丶 夕夏残阳落幕 提交于 2019-12-04 06:07:49
During my profile report of assembleDebug gradle task I discovered two realm related gradle sub-tasks which takes quite big amount of time: assembleDebug - 1m21.44s - transformClassesWithRealmOptionalAPITransformerForDebug - 22.386s - transformClassesWithRealmTransformerForIdeDebug - 10.062s Questions: what exactly those realm related gradle sub tasks do? Can I skip them at some point? why they took so long? (22 + 10 = 32 sec) Update As a workaround I am skipping task via -x script parameter assembleDebug -x transformClassesWithRealmOptionalAPITransformerForDebug

Realm.io Android best approach to get last 20 items from a table

我与影子孤独终老i 提交于 2019-12-04 05:48:57
In a table of let say 100 items, which is the best approach to get the last 20 objects. One way I can think of is to load all the objects , reverse the array , create a new array and loop from the results for 20 times filling the new array and return it. Something like as follows : public ArrayList<DataObject> getLastItems (int qty){ RealmResults<DataObject>results = realm.where(DataObject.class).findAll(); Collections.reverse(results); ArrayList<DataObject>arrayList = new ArrayList<>(); for (int i = 0; i == qty; i++){ arrayList.add(results.get(i)); } return arrayList; } Is there a better

Cannot read property 'debugHosts' of undefined

↘锁芯ラ 提交于 2019-12-04 04:51:10
问题 I'm getting this error while trying to use Realm with RN 0.29 Stack trace from chrome: "Cannot read property 'debugHosts' of undefined" handleException @ ExceptionsManager.js:55 handleError @ InitializeJavaScriptAppEngine.js:136 reportFatalError @ error-guard.js:30 guardedLoadModule @ require.js:60 _require @ require.js:49 (anonymous function) @ require-0.js:1 executeApplicationScript @ debuggerWorker.js:18 onmessage @ debuggerWorker.js:33 The device is pointing to the index.js file in the

Realm Xamarin LINQ Object

只愿长相守 提交于 2019-12-04 04:50:28
问题 What is the correct way to query Realm with LINQ where the query includes fields from other Realm objects? For example: public class Department : RealmObject { [Primary Key] public string UniqueId { get; set; } } public class Employee : RealmObject { [Primary Key] public string Name { get; set; } // Parent public Department Department { get; set; } } Then I would expect to be able to do something like: var employee = realm.All<Employee>().SingleOrDefault( e => e.Department.UniqueId == fooId &

Realm date-query

℡╲_俬逩灬. 提交于 2019-12-04 04:19:40
In my RealmSwift (0.92.3) under Xcode6.3, how would I // the Realm Object Definition import RealmSwift class NameEntry: Object { dynamic var player = "" dynamic var gameCompleted = false dynamic var nrOfFinishedGames = 0 dynamic var date = NSDate() } The current tableView finds the number of objects (i.e. currently all objects) like follows: func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int { if let cnt = RLM_array?.objects(NameEntry).count { return Int(cnt) } else { return 0 } } First question: How would I find the number of objects that have a date-entry after

App crash when trying to load a large amount off data into my app

自古美人都是妖i 提交于 2019-12-04 04:18:02
问题 I am trying to load a JSON of 40 000+ records into my Realm Database . Here is my function AFJSONRequestOperation *operation = [[AFJSONRequestOperation alloc]init]; [AFJSONRequestOperation addAcceptableContentTypes:[NSSet setWithObject:@"text/html"]]; operation = [AFJSONRequestOperation JSONRequestOperationWithRequest:request success:^(NSURLRequest *request, NSHTTPURLResponse *response, id JSON) { NSArray *relations = [JSON copy]; NSLog(@"COUNT SI %d",relations.count); dispatch_async(dispatch

Filter realm objects to only get one (distinct) object by attribute

独自空忆成欢 提交于 2019-12-04 04:03:28
问题 Let me explain first cause title may be a bit confusing. Say I have this realm objects of type Movie: Movie1(id: 0, genre: "horror") Movie2(id: 1, genre: "horror") Movie3(id: 3, genre: "sci-fi") What I need to do is get the first for every genre (in this case Movie1 and Movie3 ) I'd like to do it w/o loops using only realm + NSPredicate , so the performance is better, but I'm a bit stuck there... So far what I got is this: Realm().objects(Movie.self).sorted(byKeyPath: id, ascending: true)