Android – get started with sugarorm 1.4

I'm trying to figure out how to use sugarorm (version 1.4, imported with gradle)

I have a simple object with a public string name field

I construct this simple object with this name and save it as this (using test_type random string):

    CustomObject type = new CustomObject(TEST_TYPE);
    long l=type.save();
    Toast.makeText(this, "Type ajouté ! id="+l, Toast.LENGTH_SHORT).show();

My log now shows id = 14, so I think writing is normal

But when I want to read, it doesn't make any sense:

>Customobject.count (customobject. Class) returns 14 > customobject.findbyid (customobject. Class, 2) returns null > customobject.first (customobject. Class) returns null > customobject.find (lifeeventtype. Class, "name =?", new string [] {test_type}) returns null

I don't know if it is relevant, but I get this exception in the warning log: java.lang.nosuchmethodexception: < init > in com.orm.sugarrecord.find (sugarrecord. Java: 196) (this code is too advanced for a rookie like me...)

What on earth did I do wrong?

resolvent:

This happens when you do not provide an empty constructor

Sugarcorm can save entities correctly, but cannot instantiate them when trying to execute a selection query

The solution is to include an empty constructor and getter / setter in the entity

public CustomObject(){}

More documents here

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>