Android Realm – Database Configuration

Realm Database Configuration Example in Android and Java

— A Realm is an instance of a Realm Mobile Database container.
— Default Realm configuration uses the Realm file “default.realm” located in Context.getFilesDir().
— To use another configuration, you would create a new RealmConfiguration object.
— The RealmConfiguration can be saved as a default configuration.
— Setting a default configuration in your custom Application class makes it available in rest of your code.


Android Realm – Initialize Database

Initialize Realm Database Example in Android and Java

— Before you can use Realm in your application, you must initialize it.
— This only has to be done once using method Realm.init(context);
— A good place to initialize Realm is in onCreate method of an application subclass.
— If you create your own application subclass, you must add it to the AndroidManifest.xml


Android Realm – Insert JSON Object

Realm Insert JSON Object Example in Android and Java – Realm Database

— You can add a JSON object that maps to a RealmObject to Realm.
— The JSON object can be a String, a JSONObject or an InputStream.
— Realm will ignore any properties in the JSON not defined by the RealmObject.