Android Realm 大文件大小 [英] Android Realm large file size

查看:35
本文介绍了Android Realm 大文件大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是安卓编程的新手.我为我的简单成绩跟踪器实现了 Realm,但是,文件大小从 1.5mb 增加到 5mb.这是正常的吗?

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?

我所做的只是使用 oncreate 在每个类中添加一个领域的实例,只要活动有可能结束,就在 real.close() 中添加.还将开始和提交事务包装在每个对象创建周围.

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?

谢谢!

我的意思是 apk 大小

I mean apk size

推荐答案

@geisshirt 是对的.Realm 引入了方法public static boolean compactRealm(RealmConfiguration configuration)来压缩realm数据库.调用此方法将我的数据库大小从 +350MB 减少到 <1MB

@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

此处提供的文档:https://realm.io/docs/java/latest/api/io/realm/Realm.html#compactRealm-io.realm.RealmConfiguration-

这篇关于Android Realm 大文件大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆