I am inserting 150,000 objects in realm db. An object has only one property, which is a string. At the same time, I create a string builder with a new line for each line and finally write it to a text file.
At the end, the text file size is 0.8mb. Where the size of the db area is 18 mb. What is the reason for this. How to minimize the size of the db area. Could you help me. Here is the area insert code
private void insertWord() {
long time = System.currentTimeMillis();
StringBuilder builder=new StringBuilder();
RealmConf conf = RealmConf.getInstance(true);
int i = 0;
RealmUtils.startTransaction(conf);
while (i < 150000) {
i++;
String word = "Word:" + i;
EB eb = new EB(word);
builder.append(word+"\n");
RealmUtils.saveWord(eb, conf);
Log.i("word check" + i++, "seelog:" + word);
}
RealmUtils.commitTransaction(conf);
writeStringIntoFile(builder.toString(),0);
}
source
share