Question

I use ActiveAndroid to save my objects to the database, it works mostly well. In my application, I use the following scenario:

  • I save a new object to a table in my database
  • I select some objects from that table
  • I add them to a List<>
  • I delete everything from that table
  • I use foreach on my List and call 'save' on each object

And here comes the problem. In my table the objects are saved except the aforementioned most recently saved one. I created a counter to check, how many 'save' was called: the counter is 1 more than the count of the objects in the table. I debugged it, no exception was raised, the save was called. I use the latest version of ActiveAndroid (3.0.99)
Any ideas what I should check?

Was it helpful?

Solution

Well, the problem can be seen in the scenario if your read it through.
I copy an existing object to the memory and try to reinsert it. The ORM checks only the mID of the object and if it is not null, it calls an update. As my object had an id, it was tried to be updated though the table was truncated so nothing was updated.
I don't know if it is intentional that the model never checks the table just its own id but it can lead to issues like this.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top