How to display a Realm database content?

2.3k Views Asked by At

I have Realm database on Android phone. And I am trying to save data to Realm database and then to fetch it from there. But I am not sure that I am doing it rightly, because it does not contain some data. I want to see that records in their raw state to understand where am I wrong. But gradle failing to build project on this. Does anybody know how to see with data with some other tools? Thanks. gradle-4.4.1

    io.realm:realm-gradle-plugin:5.1.0
    implementation 'com.facebook.stetho:stetho:1.5.0'
    implementation 'com.uphyca:stetho_realm:2.2.0'

Stetho.initialize(
                Stetho.newInitializerBuilder(this)
                        .enableDumpapp(Stetho.defaultDumperPluginsProvider(this))
                        .enableWebKitInspector(Stetho.defaultInspectorModulesProvider(this))
                        //.enableWebKitInspector(RealmInspectorModulesProvider.builder(this).build())
                        .build());


buildscript {
    repositories {
        jcenter()
        mavenCentral()
        maven {
            url 'https://maven.google.com'
        }
        maven { url 'https://github.com/WickeDev/stetho-realm/raw/master/maven-repo' }
    }
}
apply plugin: 'com.android.application' //here shows error: Failed to resolve: com
apply plugin: 'io.fabric'

android {
2

There are 2 best solutions below

1
On BEST ANSWER

There is another manual way to view records of Realm database but you need Mac OS for that.

1- Run your app in emulator.

2- Go to Tools -> Android Device Monitor

3- Find your app's package name, now you can see all files of your app.

4- Find realm file and Copy it by exporting it to your computer.

5- Now install Realm Browser on MAC OS.

6- Open copied file of database via Realm browser.

You can see all tables and records of your database.

8
On

As per this issue, Stetho-Realm works with Realm 4.0.0+ if you use the newer version managed by WickeDev:

repositories {
    mavenCentral()
    maven {
        url 'https://maven.google.com'
    }
    jcenter()
    maven { url 'https://github.com/WickeDev/stetho-realm/raw/master/maven-repo' }
}

dependencies {
    implementation 'com.uphyca:stetho_realm:2.3.0'
}
val realmInspector = RealmInspectorModulesProvider.builder(this)
            .withDeleteIfMigrationNeeded(true)
            .build()

Stetho.initialize(Stetho.newInitializerBuilder(this)
            .enableDumpapp(Stetho.defaultDumperPluginsProvider(this))
            .enableWebKitInspector(realmInspector)
            .build())