uPhyca/stetho-realm

Working Configuration....

Opened this issue · 3 comments

The documentation on the readme file results is not working. Here's the "config" that I use and works.


import android.app.Application;
import android.content.Context;
import com.facebook.stetho.Stetho;
import com.uphyca.stetho_realm.RealmInspectorModulesProvider;
import io.realm.Realm;
import io.realm.RealmConfiguration;
import java.util.regex.Pattern;

public class BaseApplication extends Application {
  @Override public void onCreate() {
    super.onCreate();

    initializeStetho(this);

    //------ init the db ----------------
    RealmConfiguration config = new RealmConfiguration.Builder(this).deleteRealmIfMigrationNeeded().name("TheDb.realm").build();
    Realm.setDefaultConfiguration(config);
  }

  private void initializeStetho(final Context context) {

    Stetho.initialize(Stetho.newInitializerBuilder(context)
        .enableDumpapp(Stetho.defaultDumperPluginsProvider(context))
        .enableWebKitInspector(RealmInspectorModulesProvider.builder(context)
            .withDescendingOrder()
            .withLimit(1000)
            .databaseNamePattern(Pattern.compile(".+\\.realm"))
            .build())
        .build());
  }
}

if anyone has the same trouble as me... and doesn't want to spend 30min for this...

@zaki50 Kindly update readme :)

@kazaky thanks.

I think new RealmConfiguration.Builder(this) triggers loading of native library of Realm.

In Realm-Java 2.0 or later, I think it's enough to add Realm.init(this);.
I've updated the README in this way. And I'll update the README in release_1.x branch as well.