I'm using ActiveAndroid
library. I need to get a list of my objects sorted by the integer
field. here is how I'm trying to do that:
public static List<Category> getCategories() {
try {
return new Select()
.all()
.from(Category.class)
.orderBy("NumInRow ASC") // NumInRow is my int field
.execute();
} catch (Exception ignored) {
return null;
}
}
Am I right?
Yes Absolutely ,what you have done is Correct way to order the column,it doesn't matter whether it is a int or some other data type.
Example :
public static List<Item> getAll(Category category) {
// This is how you execute a query
return new Select()
.from(Item.class)
.where("Category = ?", category.getId())
.orderBy("Name ASC")
.execute();
}
Active Android Complete Guide Using Active Android