I am new to ormlite and i want to set default value for some fields like
@DatabaseField(generatedId = true, canBeNull = false)
int id;
@DatabaseField(canBeNull = true)
String user_type;
@DatabaseField(canBeNull = true)
String username;
@DatabaseField(canBeNull = true)
String password;
@DatabaseField(canBeNull = true)
int id_color;
I have to set the default value for the username field. How do I do this? Thanks in advance!!!!
I have to set the default value for the username field. How do I do this?
I've spent a lot of time on the ORMLite documentation. You should always start there. If you go to the documentation index, and look up default value it would show you that there is a defaultValue
field in @DatabaseField
annotation. Here are the javadocs for that field.
Something like the following should work:
@DatabaseField(defaultValue = "unknownName", canBeNull = true)
String username;
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