嗨,在我的应用程序中,我需要从RealmObject(PlayList.class)获取RealmList。问题是我试图在其他线程上这样做。(一些带有tick()方法的循环引擎)所以我的解决方案是从RealmObject中获取RealmList并将其转换为ArrayList,然后在任何线程中对其执行我想要的操作。
这就是我得到的崩溃
java.lang.IllegalStateException: Realm access from incorrect thread. Realm objects can only be accessed on the thread they were
我希望从RealmObject的Realm中“分离”一个RealmObject,这意味着我希望能够从一个方法返回一个RealmObject,并且能够在Realm close Realm实例之后使用它。
就像这样:
public Person getPersonWithId(final Context context, final String personId){
Realm realm = Realm.getInstance(context);
Person person = realm.where.....;
realm.close();
return pe
基于 这个 回答时,我发现我不能从另一个线程访问realm对象,但从答案中,我知道我可以存储realmobject的引用,然后在另一个线程中使用它。 我想循环它直到它被插入,但问题是我不能访问 和 在另一个线程上。那么我怎么才能找到解决这个问题的办法呢? private async void UpdateNotifications_OnAdd(object sender, EventArgs e)
{
//UpdateNotification is my RealmObject
var s = (UpdateNotifications)sender;
//Here I
我有一个存储在单例中的RealmObject User,并在整个应用程序中进行访问--它是在UI线程上检索的。该对象表示登录用户,并与Item类有一对多的关系。当在事务中更改它时,例如:
RealmSingleton.getUserInstance().executeTransactionAsync(new Realm.Transaction() {
@Override
public void execute(Realm realm) {
User user = realm.where(User.class).equalTo("mId",User
我正在扩展的上执行领域插入,如下所示:
public class NLService extends NotificationListenerService {
@Override
public void onNotificationPosted(StatusBarNotification sbn) {
// building realmObject here
mRealm = Realm.getDefaultInstance();
RealmHelper.saveObj(myRealmObject, mRealm);
我在我的项目中跟踪了RealmObjects
class A extends RealmObject {
...
private B b;
private RealmList<C> c;
//Getter and Setters
}
class B extends RealmObject {
...
private RealmList<D> d;
//Getter and Setters
}
class C extends RealmObject {
...
private String str1;
pri
我有下表,其中有一个PrimaryKey。我在表中插入了一些值。现在,我需要更新特定行中的特定值。我有一个以gameType作为Puzzle的行,我需要更新行中的currentLevel。但我无法做到这一点。
GamesDetails表:
public class GamesDetail extends RealmObject {
@PrimaryKey
private String gameType;
private int currentLevel;
private int totalLevel;
private int totalCoins;
我使用Realm来实现我的持久性。现在我真的很困惑该不该使用realm。
我正在使用almofire,ObjectMapper和Realm以下是我的代码。
UserInfo
class UserInfo:Object,Mapper
{
dynamic var name:String?
dynamic var accountTye:String?
dynamic var loginResult: String?
}
一旦我从我的登录服务器获得成功响应。
========= UserSessionManager
var userInfo:UserInfo?
UserSessionMana
我有两个服务,其中一个是生产者(将对象保存到领域),其他则从领域读取该对象,并将它们发送到调度任务中的REST服务。
我的例外是:
java.lang.IllegalStateException: Realm access from incorrect thread. Realm objects can only be accessed on the thread they were created.
服务1:
this.scheduler.schedule("*/2 * * * *", new Runnable() {
public void run()
第一个问题:我可以将我的文件名重命名为不同的文件名吗?比如"securedfile.realm"?因为我和default.realm在一起
第二个问题:假设我用来自App1的"securedfile.realm“来命名我的dbrealm。如果我在App2中也将我的dbrealm命名为"securedfile.realm“,该怎么办?他们只会访问一个文件吗?是可以分享的吗?
我这里有我的dbPath代码。
public class RealmDBAccessVariable
{
public static readonly string dbPath =
场景
我有一个典型的UI线程和工作线程场景。我做了一些工作,并将结果写到工作线程中的领域。结果是一个带有一些字符串字段的简单RealmObject。完成之后,我将UI线程上的事件发送到我的活动(使用Otto事件总线)来报告工作已经完成。
在我的活动中接收到事件时,我查询结果,字符串字段没有用写值进行更新。
在工作线程上:
// Did some work. Got some result
// Write to realm
try {
realm = Realm.getDefaultInstance();
realm.executeTransaction(new Realm
也许我错过了一些很简单的东西,但我还是会问.
我正在使用Xamarin窗体(.NET标准项目)、MVVMLight、领域DB和ZXing条形码扫描仪。
我有一个这样的现实..。
public class Participant : RealmObject
{
public string FirstName {get; set;}
public string LastName {get; set;}
public string Email {get; set;}
public string RegistrationCode {get; set;}
//M
型号:
public class Dog extends RealmObject {
@PrimaryKey
public String id = UUID.randomUUID().toString();
... other random String attributes
public Dog mother;
}
活动:
public class CustomActivity extends AppCompatActivity {
private Realm realm;
private Dog dog = new Dog();
@Override
pro
我正在尝试从BaseModel扩展我的模型,然后实现RealmModel。
@RealmClass
public class User extend BaseModel implements RealmModel
但是它抛出了一个错误:
error: Realm model classes must either extend RealmObject or implement RealmModel to be considered a valid model class
请帮帮忙。