【发布时间】:2016-06-22 10:49:13
【问题描述】:
我正在尝试检索一些数据并在 AsyncTask 中更新它们。
问题是我得到一个 Realm access from incorrect thread. Realm objects can only be accessed on the thread they were created.
错误,即使我在异步任务中更新我的领域实例。
这是我的代码:
new AsyncTask<Void, Void, Void>(){
@Override
protected Void doInBackground(Void... params) {
mRealm = Realm.getDefaultInstance();
// my queries & updates
return null;
}
}.execute();
【问题讨论】:
-
请发布堆栈跟踪抱怨的代码并指出问题所在的行。
标签: android multithreading android-asynctask realm