Export Realm Databases to Json and Json File
RealmExport is a Realm helper to export Realm Databases to:
You can use this Json Object to send by email or for any other things that you need.
Only increase the size of your project by 10 KB ;)
You can download an arr from maven releases page.
Or use Gradle:
repositories {
maven { url 'https://github.com/softotalss/realmexport/raw/master/maven-repository' }
}
dependencies {
implementation 'com.google.code.gson:gson:x.x.x'
implementation 'com.github.softotalss:realm_export:1.1.0'
}
You can use RealmExport
in any part of your code, but it’s recommended that you use it in a background task.
// Export to Json:
JsonObject dbJson = RealmExport.init((new RealmConfiguration.Builder()).build()).toJson();
// Export to Json File:
RealmExport.init((new RealmConfiguration.Builder()).build()).toJsonFile("path/bd.json");
Not forget replace “(new RealmConfiguration.Builder()).build()” for your specific Realm Configuration
// You can use different initializations:
RealmExport.init(RealmConfiguration configuration, String nullValue, DateFormat dateTimeFormatter)
RealmExport.init(RealmConfiguration configuration, String nullValue)
// For nullValue: "[null]"
// For dateTimeFormatter: SimpleDateFormat.getDateTimeInstance(SimpleDateFormat.LONG, SimpleDateFormat.LONG)
Alejandro Santana - @softotalss on GitHub
This project is based on stetho-realm
BSD, part MIT and Apache 2.0. See the LICENSE file for details.