Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ActiveAndroid: Date columns not created

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?

like image 996
Liz_17 Avatar asked Oct 19 '22 03:10

Liz_17


1 Answers

It should be some caching problem. for saving Date try to use type serializer. it is so easy just read this page.

like image 55
mehdi Avatar answered Oct 21 '22 15:10

mehdi