Back to project page ActiveAndroidDemo.
The source code is released under:
This is free and unencumbered software released into the public domain. Anyone is free to copy, modify, publish, use, compile, sell, or distribute this software, either in source code form or as a co...
If you think the Android project ActiveAndroidDemo listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.gannon.activeandroiddemo.models; //from w w w . j a v a 2s .co m import com.activeandroid.ActiveAndroid; import com.activeandroid.Model; import com.activeandroid.annotation.Column; import com.activeandroid.annotation.Table; import com.activeandroid.query.Delete; import com.activeandroid.query.Select; import java.util.List; /** * Categories Table Model */ @Table(name = "Categories") public class Category extends Model { @Column(index = true) public String name; // column annotations without names will use the field name by default /** * Get associated products * @return */ public List<Product> getProducts() // associated products getter { return getMany(Product.class, "category_id"); } @Override public String toString() { return name; } /** * Get all categories * @return List of Category categories */ public static List<Category> getAll() { return new Select() .all() .from(Category.class) .execute(); } /** * Deletes all categories */ public static void deleteAll() { new Delete() .from(Category.class) .execute(); ActiveAndroid.execSQL("DELETE FROM SQLITE_SEQUENCE WHERE NAME = 'Categories'"); } }