I am new to android programming. I implemented Realm for my simple grade tracker, however, the file size has grown from 1.5mb to 5mb. Is that normal?
What I simply
As said in the previous answers, sometimes is needed to conpact default.realm file because it can increases if you do a lot of realm operations. I found this file with 1.7GB after to do a heavy test processing a lot of registers with different threads.
After configuring the realm to compact as I show bellow, this file was reduced to < 1MB.
More details in Realm API - CompactRealm
But a easy way to do that is calling the method compactOnLaunch when realm configuration is building.
Realm.init(this);
objRealmConfig = new RealmConfiguration.Builder()
.schemaVersion(2)
// WARNING: Use compact to reduce the size of default.realm. A Realm file usually contain free/unused space.
// This method removes this free space and the file size is thereby reduced
// If the app do a lot of operations with Realm, use this method to compact and release free/unused space.
// More details in: https://realm.io/docs/java/latest/api/io/realm/Realm.html#compactRealm-io.realm.RealmConfiguration-
.compactOnLaunch()
.build();
Realm.setDefaultConfiguration(objRealmConfig);