1

I would like to remove the data on my ObjectBox database in Android based on its Id. Is this correct?

Box<Cart> box = ObjectBox.get().boxFor(Cart.class);
    Cart order = box.get(id);
    box.remove(order);

Thank you

vidalbenjoe
  • 921
  • 13
  • 37

1 Answers1

1

The remove method is overloaded and there are variants accepting the following arguments:

  • entity object
  • ID (long)
  • java.util.Collection objects
  • long... ids
  • T... objects

Thus, you can directly remove by ID like this:

box.remove(id);

For more details, please check the API docs of the Box class.

Markus Junginger
  • 6,950
  • 31
  • 52