Im very statisfied with SugarOrm for Android, but I ran into an issue. I'm using it with GSON for Json serializations and I want to get rid of SugarRecord
's id attribute. I know I should use @Table
annotation and later exclude specific field from serialization using @Expose
, but after annotating class with @Table I cannot use .save()
, delete()
,... methods on the object, as it is the case extending SugarRecord
. I don't know how to persist objects using @Table
annotation.
I found the documentation here very limited.
The document hasn't been updated for the annotation based persistence yet. The methods save(), delete() will be available as static methods on SugarRecord class.
So instead of doing this:
object.save()
You'd be doing this:
SugarRecord.save(object)
Check out some tests here to understand better. https://github.com/satyan/sugar/tree/master/example/src/test/java/com/example/sugartest
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