我们开始在Android应用程序项目中使用Realm.io。但是我们不喜欢Realm.ioAPI的一点是没有任何异步方式来查询数据库。在旧项目中,我们使用DbQuery和Sqlite,因此我们习惯于在线程或AsyncTask中进行数据库查询。但令人不安的是,在所有示例中,查询都是在UiThread中进行的。这对应用程序性能来说不是一件坏事吗?我们尝试在线程或AsyncTasks中进行查询,但是当我们在UiThread中访问我们的模型对象时出现错误,说我们无法在不是查询它们的线程中访问RealObjects。这是我们的示例代码:service.getDatabaseHelper().wi
适用于大多数全新安装,但在最新的应用程序更新后出现了很多关于此问题的报告。更新之间已经有一段时间了,所以我认为这可能是由于用户在我添加模式之前从非常旧的版本更新造成的......但其他人说他们已经从全新安装中看到了这一点。JavaRealm是realm-gradle-plugin:5.1.1感谢任何帮助,谢谢!错误:Causedbyio.realm.exceptions.RealmMigrationNeededExceptionMigrationisrequiredduetothefollowingerrors:-Property'Loan.loanRatePct'hasbeenmad
Doctor包含对象Organization子对象:@PrimaryKeyprivateintdoctorId;privateFullNamefullName;privateAgeage;privateOrganizationorganization;privatePositionposition;privateStringcategory;privateStringloyalty;privateListspecializations;privateContactscontacts;组织模型具有以下参数:@PrimaryKeyprivateOrganizationIdorganizat
我像这样添加了单个用户的数据:Realmrealm=Realm.getDefaultInstance();newUser=newUserDatabase();realm.executeTransaction(newRealm.Transaction(){publicvoidexecute(Realmrealm){newUser.setClassName(classSectionName);newUser.setClassNO(classNO);newUser.setImageUrl(imageUrl);newUser.setRollNo(rollNO);newUser.setSchoo
我使用的是Realmv0.80.1,我正在尝试为我添加的新属性编写迁移代码。该属性是一个RealmList。我不确定如何正确添加新列或设置一个值。我有:customRealmTable.addColumn(,"列表");正确添加该列后,我将如何为列表属性设置初始值?我想做类似的事情:customRealmTable.setRealmList(newColumnIndex,rowIndex,newRealmList()); 最佳答案 从Realmv1.0.0(可能更早)开始,您可以简单地调用RealmObjectSchema#addR
我想将Realm字段的数据类型从String更改为int并且仅供引用,该字段也是一个PrimaryKey。我在RealmMigration中找不到解决此问题的方法。PS:我的应用已经投入生产,该字段中当前的所有值都是整数。编辑1我的模型类publicclassTeamextendsRealmObject{@SerializedName("id")@PrimaryKeyprivateintid;@SerializedName("name")privateStringname;@SerializedName("description")privateStringdescription;}在
我需要在Realm模型中实现Parcelable接口(interface),但我不知道如何在Parcel中编写RealmList这是我的代码:publicclassSomeModelextendsRealmObjectimplementsParcelable{publiclongid;publicRealmListotherModels;protectedSomeModel(Parcelin){id=in.readLong();//hereineedtootherModelRealmListfromparcel}@OverridepublicvoidwriteToParcel(Parc
直到现在,我还在我的安卓系统中使用RealmnewRealmConfiguration.Builder(this).build();我只是稍后阅读有关添加模式和迁移的可能性的信息。所以在我的应用程序的新版本中,我想添加迁移功能。所以我将上面的行更改为:newRealmConfiguration.Builder(this).schemaVersion(0).migration(newMigration()).build();但是现在我得到了错误IllegalArgumentException:Configurationscannotbedifferentifusedtoopenthesa
这个问题在这里已经有了答案:"realmmigrationneeded",exceptioninandroidwhileretrievingvaluesfromrealmdb(5个答案)关闭5年前。每当我更改模型(如添加更多字段)时,应用程序就会崩溃并出现io.realm.exceptions.RealmMigrationNeededException错误。这只能在我卸载并重新安装应用程序后才能解决。有什么迁移建议吗?我仅使用默认实例。
在下面的Realm示例中,我创建了两个模型。一个称为任务,另一个称为用户。在Realm的帮助下,我将使用一对一关系。IE。用户“Theo”有一个任务。这是我的模型。@RealmClasspublicclassTaskimplementsRealmModel{publicStringgetId(){returnid;}publicvoidsetId(Stringid){this.id=id;}publicStringgetTitle(){returntitle;}publicvoidsetTitle(Stringtitle){this.title=title;}publicStringg