实体类  用ViewUtils附加了注解  DbUtils可以直接创建数据库根据实体类的注解创建数据库的表

 1 package com.qianfeng.xutilsshow.model;
 2 
 3 import com.lidroid.xutils.db.annotation.Column;
 4 import com.lidroid.xutils.db.annotation.Id;
 5 import com.lidroid.xutils.db.annotation.Table;
 6 
 7 
 8 /**
 9  * Created with IntelliJ IDEA.
10  * User: vhly[FR]
11  * Date: 15/10/9
12  * Email: vhly@163.com
13  */
14 
15 @Table(name = "books")
16 public class Book {
17 
18     @Id   // _id integer primary key autoincrement
19     private long _id;
20 
21     @Column
22     private String title;
23 
24     @Column
25     private float price;
26 
27     @Column
28     private String author;
29 
30     public long getId() {
31         return _id;
32     }
33 
34     public void setId(long id) {
35         this._id = id;
36     }
37 
38     public String getTitle() {
39         return title;
40     }
41 
42     public void setTitle(String title) {
43         this.title = title;
44     }
45 
46     public float getPrice() {
47         return price;
48     }
49 
50     public void setPrice(float price) {
51         this.price = price;
52     }
53 
54     public String getAuthor() {
55         return author;
56     }
57 
58     public void setAuthor(String author) {
59         this.author = author;
60     }
61 }
Book

相关文章: