Skip to content
kymjs edited this page Nov 12, 2015 · 2 revisions

#DBLibrary Summary DBLibrary 来自开源项目 afinal->finalDB
in android orm framework. Make use of sqlite handle. one line just to add/delete/update/query. holder one-more,more-one entity 一个Android中的orm框架。你可以使用一行代码对sqlite做增删改查操作,并且知道一对多多对一关联字段。

	// data file
	KJDB db = KJDB.create(this);
	User ugc = new User(); //warn: The ugc must have id field or @ID annotate
	ugc.setEmail("[email protected]");
	ugc.setName("kymjs");
	db.save(ugc);
	//one - many
	public class Parent{  //JavaBean
		private int id;
		@OneToMany(manyColumn = "parentId")
		private OneToManyLazyLoader<Parent ,Child> children;
		/*....*/
	}
	
	public class Child{ //JavaBean
		private int id;
		private String text;
		@ManyToOne(column = "parentId")
		private  Parent  parent;
		/*....*/
	}
	
	List<Parent> all = db.findAll(Parent.class);
			for( Parent  item : all){
				if(item.getChildren ().getList().size()>0)
					Toast.makeText(this,item.getText() + item.getChildren().getList().get(0).getText(),Toast.LENGTH_LONG).show();
			}
Clone this wiki locally