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)
does the trick or not.
if((int)Email_Message.count(Email_Message.class, "message_type = 1", null) == 0)
This worked for me, turns out Sugar ORM also likes to rename the variables like this.