Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
284 views
in Technique[技术] by (71.8m points)

java - Android Realm large file size

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 did was add in an instance of realm on every class with oncreate, added in realm.close() whenever there was a chance that the activity would end. Also wrapped the begin and commit transaction around each object creation.

Is there something I did wrong that ended up with the massive file size?

Thanks!

Edit: I mean apk size

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

@geisshirt is right. Realm have introduced the method public static boolean compactRealm(RealmConfiguration configuration) to compact the realm database. Calling this method reduced the size of my database from +350MB to <1MB

Documentation available here: https://realm.io/docs/java/latest/api/io/realm/Realm.html#compactRealm-io.realm.RealmConfiguration-


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...