Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Reducing size of Realm database shipping with app

Am making a Dictionary as my First android Project when the app is Run first time am using

RealmConfiguration config = new RealmConfiguration.Builder(this)
            .name(Realm.DEFAULT_REALM_NAME)
            .migration(new Word())
            .assetFile(this,"Default.realm")
            .schemaVersion(1)
            .build();

    realm=realm.getInstance(config);

this Code to create my Shipped in .realm File as a Default Realm DataBase But the Size of the Database is Huge after Normalizing as around 20MB Is there a better way to Ship .realm File so as to reduce it's size.
Already tried shipping as csv but taking too much time to convert to .realm

like image 474
phpdroid Avatar asked Nov 29 '25 15:11

phpdroid


1 Answers

I am facing same issue. I have pre populated sqlite of 2.5 MB in my android asset folder but when I migrated to realm I got same data with 75MB file.

I try to reduce the size and I got a one solution. May be that help you out.

Open Realm Browser -> File -> Export -> Compacted Realm.

After that I got 3.5MB file.

like image 125
Hafiz Waleed Hussain Avatar answered Dec 01 '25 03:12

Hafiz Waleed Hussain