realm

Replaced List<T> object not persisting consistently in Realm

狂风中的少年 提交于 2019-12-11 11:06:56
问题 I have a List<Workout> object that occasionally needs to be sorted (e.g., if a user adds a Workout out of order), but I can't seem to get the new sorted List<Workout> to persist. My code works the moment it runs (i.e., it shows up on the view as sorted), but when I exit the ViewController or restart the app, I see nothing. The nothing is due to the exercise.workoutDiary.removeAll() persisting, but apparently the subsequent assignment to the exercise.workoutDiary = sortedWorkoutDiary is not

How I can use Realm to parse a large JSON and storing data

ε祈祈猫儿з 提交于 2019-12-11 10:42:20
问题 J'm really blocked into parsing and storing data using Realm,I have a large JSON and I creat all the class models like the example of RealM. this is my error :Caused by: org.json.JSONExcept ion: Value fr at 0 of io.realm.exceptions.RealmException: Could not map Json at io.realm.Realm.createObjectFromJson(Realm.java:860) at com.example.volleyapp2.ImagesActivity$ImagesFragment.loadData(ImagesActivity.java:179) at com.example.volleyapp2.ImagesActivity$ImagesFragment$2.onResponse(ImagesActivity

How to pass realm.objects(SomeObject.self).filter() to a function that needs Results<Object>

ⅰ亾dé卋堺 提交于 2019-12-11 10:12:56
问题 This question is in conjunction with RealmSwift Cannot cast Results<SomeOjbect> to Results<Object> I have a Realm Object like: import RealmSwift class SomeObject: Object { @objc dynamic var datetime = "" @objc dynamic var city = 0 convenience init(city: Int, datetime: String) { self.init() self.city = city self.datetime = datetime } } There is a framework: https://github.com/danielgindi/ChartsRealm, which pull data from Realm and draw charts. The framework is written in Swift, and can be used

Realm - Querying long-type class returns empty

只愿长相守 提交于 2019-12-11 08:46:18
问题 When querying equalTo a field with long type, the RealmResults returns blank. My query code is as below: _realm.beginTransaction(); long albumID = Long.valueOf(albumId); results = _realm.where(Image.class).equalTo("albumId",albumID).findAll(); _realm.commitTransaction(); albumId is a string passed by a method Image class: public class Image extends RealmObject { @PrimaryKey private long id; private long albumId; private String url; private int width; private int height; private long published

Realm issue with Swift 3.1

我的未来我决定 提交于 2019-12-11 08:41:20
问题 I've just updated Xcode using Swift 3.1. While waiting for Realm to update their library, just wondering if someone has a temporary workaround for this issue. Module compiled with Swift 3.0.2 cannot be imported in Swift 3.1: RealmSwift.framework EDIT: @matt, @bdash, I followed the instruction, removed the old libraries and added new supporting swift 3.1. I got this error Showing All Issues Command failed due to signal: Illegal instruction: 4 Any idea? 回答1: Realm Swift v2.5.0, released earlier

How to fix “Object is not part of the schema for this Realm”

我是研究僧i 提交于 2019-12-11 08:14:25
问题 I'm trying to set up an application that uses the Realm database but I can't seem to make it work. I've also disabled Instant Run but that didn't solve the problem either. Here are my code files: App level build.gradle apply plugin: 'com.android.application' apply plugin: 'kotlin-android-extensions' // <-- these two were the problem apply plugin: 'kotlin-android' // <-- apply plugin: 'com.google.gms.google-services' apply plugin: 'realm-android' Project level build.gradle dependencies{

Unable to find generated Parcelable class

空扰寡人 提交于 2019-12-11 08:07:35
问题 I am trying to use Parceler in my android project. This is my Song model. @Parcel(implementations = {SongRealmProxy.class}, value = Parcel.Serialization.BEAN, analyze = {Song.class}) public class Song extends RealmObject { @PrimaryKey public String id; public String isrc; public String songName; public String artistName; public String album_id; public String albumArtUrl; public String genre_id; public String genreName; public String releaseYear; public String price; public String lyrics;

How to manage realm instance?

杀马特。学长 韩版系。学妹 提交于 2019-12-11 07:39:20
问题 I have an Activity that manage multiples fragments and nested fragment, like that : Activity -> RootFragment1 -> NestedFragment1, NestedFragment2 -> RootFragment2 -> NestedFragment3, NestedFragment4 ... I use to get a realm instance and close it in each nested fragment in onStart, onStop methods but sometimes I meet this exception : Fatal Exception: java.lang.IllegalStateException: This Realm instance has already been closed, making it unusable. Is there a recommended way to get a Realm

List is not conforming to Encodable

蹲街弑〆低调 提交于 2019-12-11 07:35:46
问题 So, I'm using realm and I have the following relationship between two models: A unit has many tests : // Unit model class Unit: Object, Decodable { @objc dynamic var id: String = "" ... let tests = List<Test>() enum CodingKeys: String, CodingKey { case id ... //case tests = "complete_control_tests" } convenience required init(from decoder: Decoder) throws { self.init() let container = try decoder.container(keyedBy: CodingKeys.self) id = try container.decode(String.self, forKey: .id) ... if

Realm Android : io.realm.exceptions.RealmException: 'DomainModel' doesn't exist in current schema

柔情痞子 提交于 2019-12-11 07:06:25
问题 I am using realm db in android application I have integrated realm db as per documents which is as follows: build.gradle(Project Level) dependencies { classpath 'com.android.tools.build:gradle:2.3.3' classpath 'com.neenbedankt.gradle.plugins:android-apt:1.4' classpath "io.realm:realm-gradle-plugin:3.7.0" // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } build.gradle(App level) apply plugin: 'com.android.application' apply