dimanche 27 septembre 2015

Android ORMs failing to select new inserted rows

I have an app that has 2 Activities and 1 Sqlite DB: 1. MainActivity - contains a TableLayout with some data from a table. 2. EntryActivity - used for adding/updating and Entry.

I've used every ORM for Sqlite I could find: Sugar ORM, ActiveAndroid, Rush, DbFlow and still the issue persists. Issue details: MainActivity is loaded, let's say 10 rows are fetched from the DB, everything is OK. EntryActivity is loaded with startActivityForResult, data is entered, Save button is pressed, the record gets inserted in the DB successfully. MainActivity is notified via setResult() and finish() on EntryActivity. It is now supposed to remove all the TableRows and reload the data from the DB. The select statement does NOT return the newly-inserted rows, only the old ones.

I tried executing the select statement right after newElement.save() (in EntryActivity) and, surprise, it works there.

I don't use threads, no async processing.

Right now I use ActiveAndroid, it is set up correctly, all classes are loaded at start, nothing seems to be wrong.

I belive the issue comes from changing the Context. I initialise ActiveAndroid in a class that extends android.app.Application.

Please, help!

Thank you, Alin.

Aucun commentaire:

Enregistrer un commentaire