Realm Browser for Android
Realm Browser Library is a small, but very helpful library designed for viewing and editing Realm database files on Android devices. Mobile developers using the Realm in their applications are able to view stored data faster and easier, and debug modules that work with the database. The library also provides the ability to generate data automatically. Nowadays the official Realm browser is only available for Mac OS X users. Moreover, it is necessary to copy the database file from user’s device to a PC. Using Realm Browser Library developers have an access to stored data directly in the program without having to copy the data file.
There are two ways to open the Realm Browser: developers can create a notification or call the appropriate method at the right time. The first method prevents interference in your app's user interface, the second method provides necessary flexibility.
The code is recommended to call during the application initialization.
// get Realm (use the same way as in application) Realm realm = Realm.getInstance(this); new RealmBrowser.Builder(this) // add class, you want to view .add(realm, Person.class) // call method showNotification() .showNotification();
Note: Using Gradle to build the project, developer is able to show a notification only in case of debug-version, Realm Browser notification might not be created in the release-version. Q.v. Work with build variants.
RealmBrowser initialization is identical to the example of creation of the notification, except calling show() instead of showNotification().
Realm realm = Realm.getInstance(this); new RealmBrowser.Builder(this) .add(realm, Person.class) .show();
Realm Browser lets you add either separate class or class lists for view:
Realm realm = ...; List<Class<? extends RealmObject>> classes = new ArrayList<>(); classes.add(Cat.class); classes.add(Dog.class); classes.add(Person.class); classes.add(DataTypeTest.class); new RealmBrowser.Builder(c) .add(realm, classes) .show();
In case the project uses multiple database files, simply add new Realm instances indicating, which classes are included in this database.
private static final String SECOND_REALM_NAME = "second.realm"; ... Context c = ...; Realm realm = Realm.getInstance(c); RealmConfiguration secondRealmConfig = new RealmConfiguration.Builder(c) .name(SECOND_REALM_NAME) .build(); Realm realmSecond = Realm.getInstance(secondRealmConfig); List<Class<? extends RealmObject>> classes = new ArrayList<>(); classes.add(Cat.class); classes.add(Dog.class); classes.add(Person.class); classes.add(DataTypeTest.class); new RealmBrowser.Builder(c) .add(realm, classes) .add(realmSecond, DifferentFileObject.class) .show();
We hope that you will enjoy using our product and would like to receive any feedback, comments or ideas sent to this e-mail: email@example.com
Scand is providing a full range of custom software development services. We develop software for dozens of clients world-wide, and we would be glad to do this for you. You are welcome to submit your project/product request using our contact form. We will contact you shortly to clarify all requirements.