Class DynamicRealm
이 페이지의 내용
io.realm
DynamicRealm is a dynamic variant of io.realm.Realm . This means that all access to data and/or queries are done using string based class names instead of class type references.
This is useful during migrations or when working with string-based data like CSV or XML files.
The same io.realm.RealmConfiguration can be used to open a Realm file in both dynamic and typed mode, but modifying the schema while having both a typed and dynamic version open is highly discouraged and will most likely crash the typed Realm. During migrations only a DynamicRealm will be open.
Dynamic Realms do not enforce schemas or schema versions and RealmMigration code is not used even if it has been defined in the RealmConfiguration .
This means that the schema is not created or validated until a Realm has been opened in typed mode. If a Realm file is opened in dynamic mode first it will not contain any information about classes and fields, and any queries for classes defined by the schema will fail.
다음도 참조하세요.
중첩된 클래스 요약
수정자 및 유형 | 클래스 및 설명 |
---|---|
| |
|
메서드 요약
수정자 및 유형 | 메서드 및 설명 |
---|---|
public void | Realm에 변경 리스너를 추가합니다. |
public <any> | asFlowable () 이 Realm의 변경 사항을 모니터링하는 RxJava Flowable을 반환합니다. |
새로운 내장된 객체를 인스턴스화하고 Realm에 추가합니다. | |
Creates an object with a given primary key. | |
Realm에 새 객체를 인스턴스화하고 추가합니다. | |
public void | |
public void | Executes a given transaction on the DynamicRealm. |
public RealmAsyncTask | DynamicRealm.Transaction transaction, DynamicRealm.Transaction.OnSuccess onSuccess, DynamicRealm.Transaction.OnError onError ) executionTransactionAsync(Transaction) 와 유사하지만 OnSuccess 및 OnError 콜백도 허용합니다. |
public RealmAsyncTask | DynamicRealm.Transaction transaction, DynamicRealm.Transaction.OnError onError ) executionTransactionAsync(Transaction) 과 유사하지만 OnError 콜백 도 허용합니다. |
public RealmAsyncTask | DynamicRealm.Transaction transaction, DynamicRealm.Transaction.OnSuccess onSuccess ) executionTransactionAsync(Transaction) 과 유사하지만 OnSuccess 콜백 도 허용합니다. |
public RealmAsyncTask | executionTransaction(Transaction)과 유사하지만 작업자 스레드에서 비동기적으로 실행됩니다. |
공개 DynamicRealm | freeze () 현재 Realm의 동결된 스냅샷을 반환합니다. |
public static DynamicRealm | Realm static constructor that returns a dynamic variant of the Realm instance defined by provided io.realm.RealmConfiguration . |
public static RealmAsyncTask | The creation of the first Realm instance per RealmConfiguration in a process can take some time as all initialization code need to run at that point (Setting up the Realm, validating schemas and creating initial data). |
public Realm 스키마 | getSchema () Returns the mutable schema for this Realm. |
공개 부울 | isEmpty () 이 io.realm.Realm 에 객체가 포함되어 있는지 확인합니다. |
public void | 모든 사용자 정의 변경 수신기를 제거합니다. |
public void | 지정된 변경 리스너를 제거합니다. |
공개 RealmQuery |
상속된 메서드
클래스 java.lang.Object 에서 상속된 메서드 :
getClass
,hashCode
,equals
,clone
,toString
,notify
,notifyAll
,wait
,wait
,wait
,finalize
io.realm.BaseRealm 클래스에서 상속된 메서드:
setAutoRefresh
,isAutoRefresh
,refresh
,isInTransaction
,addListener
,removeListener
,asFlowable
,removeAllListeners
,writeCopyTo
,writeEncryptedCopyTo
,waitForChange
,stopWaitForChange
,beginTransaction
,commitTransaction
,cancelTransaction
,freeze
,isFrozen
,getNumberOfActiveVersions
,checkIfValid
,checkAllowQueriesOnUiThread
,checkAllowWritesOnUiThread
,checkIfInTransaction
,checkIfValidAndInTransaction
,getPath
,getConfiguration
,getVersion
,close
,isClosed
,isEmpty
,getSchema
,getSubscriptions
,deleteAll
,migrateRealm
,finalize
메서드 세부 정보
addChangeListener
Realm에 변경 리스너를 추가합니다. 이 스레드 또는 다른 스레드에서 변경 사항이 커밋될 때 리스너가 실행됩니다. Realm instances are cached per thread. For that reason it is important to remember to remove listeners again either using removeChangeListener(RealmChangeListener) or removeAllChangeListeners() . Not doing so can cause memory leaks. 매개변수
스로우
다음도 참조하세요. |
asFlowable
public <any> asFlowable () | ||||||
---|---|---|---|---|---|---|
이 Realm의 변경 사항을 모니터링하는 RxJava Flowable을 반환합니다. 구독 시 현재 상태를 방출합니다. Realm이 업데이트될 때마다 항목이 계속 방출되며 Realm Flowable에서 방출된 항목은 동결됩니다(freeze() 참조). 즉, 변경할 수 없으며 모든 스레드에서 읽을 수 있습니다. Realm Flowable은 항상 라이브 Realm을 보유한 스레드에서 항목을 방출합니다. 즉, 추가 처리를 수행해야 하는 경우 계산 스케줄러에서 값을 관찰하는 것이 좋습니다.
반환
재정의 BaseRealm |
createEmbeddedObject
public DynamicRealmObject createEmbeddedObject ( ) |
---|
새 내장된 객체를 인스턴스화하고 Realm에 추가합니다. 이 메서드는 내장된 것으로 표시된 유형의 객체를 생성하는 데만 사용해야 합니다. 매개변수
반환 새로 생성된 내장된 객체입니다. 스로우
다음도 참조하세요. |
createObject
Creates an object with a given primary key. Classes without a primary key defined must use createObject(String) } instead. 반환 the new object. All fields will have default values for their type, except for the primary key field which will have the provided value. 스로우
|
Realm에 새 객체를 인스턴스화하고 추가합니다. 매개변수
반환 새 객체. 스로우
|
삭제
executionTransaction
Executes a given transaction on the DynamicRealm. beginTransaction() and commitTransaction() will be called automatically. If any exception is thrown during the transaction cancelTransaction() will be called instead of commitTransaction(). UI 스레드에서 이 메서드를 호출하면 RealmException이 발생합니다. 이렇게 하면 프레임 드롭 또는 ANR이 발생할 수 있습니다. 이 메서드를 UI 아닌 스레드에서 호출하거나 대신 executionTransactionAsync(Transaction)를 사용하는 것이 좋습니다. 매개변수
스로우
|
executionTransactionAsync
public RealmAsyncTask executeTransactionAsync ( DynamicRealm.Transaction transaction, DynamicRealm.Transaction.OnSuccess onSuccess, DynamicRealm.Transaction.OnError onError ) |
---|
executionTransactionAsync(Transaction) 와 유사하지만 OnSuccess 및 OnError 콜백도 허용합니다. 매개변수
반환 취소 가능한 작업을 나타내는 RealmAsyncTask 입니다. 스로우
|
public RealmAsyncTask executeTransactionAsync ( DynamicRealm.Transaction transaction, DynamicRealm.Transaction.OnError onError ) |
---|
executionTransactionAsync(Transaction) 과 유사하지만 OnError 콜백 도 허용합니다. 매개변수
반환 취소 가능한 작업을 나타내는 RealmAsyncTask 입니다. 스로우
|
public RealmAsyncTask executeTransactionAsync ( DynamicRealm.Transaction transaction, DynamicRealm.Transaction.OnSuccess onSuccess ) |
---|
executionTransactionAsync(Transaction) 과 유사하지만 OnSuccess 콜백 도 허용합니다. 매개변수
반환 취소 가능한 작업을 나타내는 RealmAsyncTask 입니다. 스로우
|
executionTransaction(Transaction)과 유사하지만 작업자 스레드에서 비동기적으로 실행됩니다. 매개변수
반환 취소 가능한 작업을 나타내는 RealmAsyncTask 입니다. 스로우
|
동결
public DynamicRealm freeze () |
---|
현재 Realm의 동결된 스냅샷을 반환합니다. 이 Realm은 IllegalStateException 을 발생시키지 않고 모든 스레드에서 읽고 쿼리할 수 있습니다. . 동결된 Realm에는 자체 수명 주기가 있으며 close() 를 호출하여 닫을 수 있지만 동결된 복사본을 생성한 Realm을 완전히 닫으면 동결된 Realm도 닫힙니다. 동결된 데이터는 정상적으로 쿼리할 수 있지만 어떤 방식으로든 데이터를 변경하거나 리스너를 등록하려고 하면 불법적인 상태 예외( IllegalStateException )가 발생합니다. . 참고: 버전이 다른 많은 수의 Realm을 활성 상태로 유지하면 Realm의 파일 크기에 부정적인 영향을 미칠 수 있습니다. 이러한 상황을 방지하려면 RealmConfiguration.Builder.maxNumberOfActiveVersions(long) 을 설정할 수 있습니다. 반환 이 Realm의 동결된 사본입니다. 재정의 BaseRealm |
getInstance
Realm static constructor that returns a dynamic variant of the Realm instance defined by provided io.realm.RealmConfiguration . Dynamic Realms do not care about schemaVersion and schemas, so opening a DynamicRealm will never trigger a migration. 반환 the DynamicRealm defined by the configuration. 스로우
다음도 참조하세요. |
getInstanceAsync
public static RealmAsyncTask getInstanceAsync ( RealmConfiguration configuration, DynamicRealm.Callback callback ) |
---|
The creation of the first Realm instance per RealmConfiguration in a process can take some time as all initialization code need to run at that point (Setting up the Realm, validating schemas and creating initial data). This method places the initialization work in a background thread and deliver the Realm instance to the caller thread asynchronously after the initialization is finished. 매개변수
반환 취소 가능한 작업을 나타내는 RealmAsyncTask 입니다. 스로우
다음도 참조하세요. |
getSchema
public RealmSchema getSchema () |
---|
isEmpty
public boolean isEmpty () |
---|
이 io.realm.Realm 에 객체가 포함되어 있는지 확인합니다. 반환 비어 있으면 재정의 BaseRealm |
모든 변경 리스너 제거
public void removeAllChangeListeners () |
---|
모든 사용자 정의 변경 수신기를 제거합니다. 스로우 다음도 참조하세요. |
removeChangeListener
위치
Returns a RealmQuery, which can be used to query the provided class. 매개변수
반환 a RealmQuery, which can be used to query for specific objects of provided type. 스로우
다음도 참조하세요. |