Answer the question
In order to leave comments, you need to log in
How to implement 1 : M relation in ActiveAndroid library?
I use the ActiveAndroid
library as a local database.
there is a Post model
package smartfoxlabs.ppos.Models;
import com.activeandroid.Model;
import com.activeandroid.annotation.Column;
import com.activeandroid.annotation.Table;
import java.util.ArrayList;
import java.util.List;
/**
* Created by dwite_000 on 24.10.2014.
*/
@Table(name = "posts")
public class Post extends Model {
@Column(name = "postID",unique = true)
public int id;
@Column(name = "type")
public String type;
//WTF?
@Column(name = "slug")
public String slug;
@Column(name = "url")
public String url;
@Column(name = "status")
public String status;
@Column(name = "title")
public String title;
@Column(name = "title_plain")
public String title_plain;
@Column(name = "content")
public String content;
@Column(name = "excerpt")
public String excerpt;
@Column(name = "PostDate")
public String date;
@Column(name = "Category")
public java.util.List<Category> categories;
@SuppressWarnings("serial")
public static class List extends ArrayList<Post> {
}
public boolean exists() {
boolean flag = false;
//Post post = new Select().from(Post.class).where("Min = ?",this.id).executeSingle();
return flag;
}
public Post() {
super();
}
}
@Table(name = "Categories")
public class Category extends Model {
@Column(name = "Mid")
public int id;
@Column(name = "slug")
public String slug;
@Column(name = "title")
public String title;
@Column(name = "parent")
public int parent;
public Category() {
super();
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question