androiddatabaseobjectbox

Maintaining only predefined limited number of entries in objectbox


I am using Objectbox db. I have a box for storing data.

I want limit the db size to 100 entries with first in first out basis.

For example if we put 101th entry, then the 1st entry should be deleted, so the db maintains maximum of 100 entries.

I know about live data model, but is there any alternative simple API, like mybox.setLimit(100); ?


Solution

  • There is no such functionality and there are no plans to provide it.

    One way to do this is a query with an offset of 100 and to delete the resulting objects.