I have an Email_Message class in my android app that stores email messages. It has an int field called "messageType". messageType == 1 means it's an inbox email, messageType == 2 means it's a sent email.
I just started with Sugar ORM and I want to check in a class how many inbox email do I have stored in the database. More accurately I want to check if I have inbox emails stored there or not, deciding if I need to fetch emails from network or database. But I cant make this if statemant work:
if((int)Email_Message.count(Email_Message.class, "messageType = ?", "1") == 0){} //no emails stored
It says the 3rd argument needs to be a String[] and I dont understand what should I put there then, the only example I could find for usage is this one . (long numberOfAuthors = Author.count(Author.class, "full_name = ?", "Timothy");)
Can someone explain to me how to use the count method correctly?
EDIT : I have to go now, but later I'll check and update the question if String[] test = {"1"}; if((int)Email_Message.count(Email_Message.class, "messageType = ?", test) == 0)
String[] test = {"1"}; if((int)Email_Message.count(Email_Message.class, "messageType = ?", test) == 0)
does the trick or not.
if((int)Email_Message.count(Email_Message.class, "message_type = 1", null) == 0)
这对我有用,结果Sugar ORM也喜欢重命名这样的变量。
One example to use String[]:
String[] vals = {
String.valueOf(LocalRecord.ImageState.Raw)
};
long n_count = HourFolder.count(HourFolder.class, "state = ?", vals);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.