Docs Menu

Interface CompactOnLaunchCallback

On this page

  • io.realm
  • Method Summary
  • Method Detail
  • shouldCompact

This interface is used to determine if a Realm file should be compacted the first time the file is opened and before the instance is returned.Note that compacting a file can take a while, so compacting should generally only be done on a background thread or when used in combination with Realm.getInstanceAsync(RealmConfiguration, io.realm.Realm.Callback) .

Modifier and Type
Method and Description
public boolean
long totalBytes,
long usedBytes
)

This method determines if the Realm file should be compacted before opened and returned to the user.

public boolean shouldCompact (
long totalBytes,
long usedBytes
)

This method determines if the Realm file should be compacted before opened and returned to the user. It is passed the total file size (data + free space) and the bytes used by data in the file.

Parameters

  • totalBytes - the total file size (data + free space).
  • usedBytes - the total bytes used by data in the file.

Returns

{code true} to indicate an attempt to compact the file should be made. Otherwise, the compaction will be skipped.

←  Enum CaseClass DefaultCompactOnLaunchCallback →
Give Feedback
© 2022 MongoDB, Inc.

About

  • Careers
  • Investor Relations
  • Legal Notices
  • Privacy Notices
  • Security Information
  • Trust Center
© 2022 MongoDB, Inc.