Android Realm - Debugging

I want to see the values ​​of the variables of a Realm object

For instance:

Student (int studentID, ArrayList <Subject> subjectList)

Subject (int subjectID, String subjectName)

I want to see item names in a student object when debugging using Android Studio.

Where should I search in the Android studio debug window to find the student in the topic list?

+4
source share
3 answers

Realm proxies your model objects and is a zero-copy storage system, so to check the value of a field, you need to use the function to evaluate the expression of the debugger.

We are considering writing a plugin for the debugger to show values ​​directly, but this is still under investigation.

+2
source

You cannot do this directly.

this is my approach.

 List<FooObject> messages = realm.copyFromRealm(value);

.

realm.where(FooObject.class).equalTo(FooObject.id, id).findAllAsync().asObservable()
            .filter(new Func1<RealmResults<FooObject>, Boolean>() {
                @Override
                public Boolean call(RealmResults<FooObject> message) {
                    return message.isLoaded();
                }
            }).subscribe(new SimpleObserver<RealmResults<FooObject>>() {
                @Override
                public void onCompleted() {
                    super.onCompleted();
                }

                @Override
                public void onNext(RealmResults<FooObject> value) {
                    super.onNext(value);
                    List<FooObject> messages = realm.copyFromRealm(value);
                    RLog.d(TAG, "Messages");
                }

                @Override
                public void onError(Throwable e) {
                    super.onError(e);
                }

                @Override
                public String getTag() {
                    return TAG;
                }
            });
0

You can use Stheto from FaceBook. You can see dynamic changes and the whole table, etc. Here is the link: https://github.com/uPhyca/stetho-realm

I will explain here: import lib from gradle with

>  compile 'com.facebook.stetho:stetho:1.5.0'
>  compile 'com.uphyca:stetho_realm:2.1.0'

then in the extends Application class (don't forget to notify the manifest about your class:

 <application
        android:allowBackup="true"
        tools:ignore="AllowBackup"
        android:name=".YourClassName"

then add this

public class YourClassName extends Application {
...
 @Override
    public void onCreate() {
     Stetho.initialize(
                    Stetho.newInitializerBuilder(this)
                            .enableDumpapp(Stetho.defaultDumperPluginsProvider(this))
                            .enableWebKitInspector(RealmInspectorModulesProvider.builder(this).build())
                            .build());

finnaly open chrome at this url

chrome://inspect/#devices 

And click on check. Go to Ressources, then to Web Sql. You can see your db this way  enter image description here

0
source

All Articles