I am trying to store a Person
object with ActiveAndroid. I set the birthdate like this: person.setBirthdate(new java.sql.Date((new Date()).getTime()));
. After assigning all data i am calling person.save();
.
I get a list of all persons from the database with this command: new Select().from(Person.class).execute();
If I do not close the app everything works fine (birthdate is always returned correctly from the database). However, when I close the app completely and then restart it, the birthdate is always null. All other fields (first name, last name etc.) are correct.
I really don't know why this is happening and would appreciate some help!
EDIT: After taking a closer look at my database I found out that the birthdate-column is not created. I am still not sure why the data is available when not closing the app though.
Second EDIT: I added a new column (a string) which is saved to the database and works just fine. So the problem is not an outdated database. All columns but the date column get created.
I also changed the date datatype to a string. The birthdate was then saved. Changing it back to a Date datatype resulted in the original problem again. Really weird... Does anyone know whats going on?
It should be some caching problem. for saving Date try to use type serializer. it is so easy just read this page.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With