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

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

问题描述

我是android编程的新手.我为简单的成绩跟踪器实现了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的类上添加一个realm实例,并在活动可能结束时添加到realm.close()中.还围绕每个对象创建包装了begin和commit事务.

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大小

推荐答案

@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-

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

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

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