对于这样实体public class Person {
public String id;
public String name;
public String iProvince;
public String iCity;
public String iZone;
public String iSchool;
public String iGrade;
public String messageInfo;
public String sendNumber;
public String receiveTime;
public String sendTime;
public long dealNum;
public long dealSuccessNum;
public long dealFailNum;
}
数据库部分这样写对吗
public class DBPersonOpenHelper extends SQLiteOpenHelper {
public static final String DATABASE_NAME = "person.db";
public static final int VERSION = 1;
public static final String TABLE_NAME = "user";
public DBPersonOpenHelper(Context context) {
super(context, DATABASE_NAME, null, VERSION);
}
public DBPersonOpenHelper(Context context,int version) {
super(context, DATABASE_NAME, null, VERSION);
}
@Override
public void onCreate(SQLiteDatabase db) {
db.execSQL("create table +"+TABLE_NAME+"(uid INTEGER primary key autoincrement,name varchar(255),number varchar(255),province varchar(255),city varchar(255),zone varchar(255),school varchar(255),grade varchar(255),class varchar(255),messageinfo TEXT,sendtime varchar(255),receivetime varchar(255),dealnumber INTEGER,successnumber INTEGER,failNumber INTEGER )");
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
System.out.println("update a database");
String sql = "drop table "+TABLE_NAME;
db.execSQL(sql);
onCreate(db);
}
public String id;
public String name;
public String iProvince;
public String iCity;
public String iZone;
public String iSchool;
public String iGrade;
public String messageInfo;
public String sendNumber;
public String receiveTime;
public String sendTime;
public long dealNum;
public long dealSuccessNum;
public long dealFailNum;
}
数据库部分这样写对吗
public class DBPersonOpenHelper extends SQLiteOpenHelper {
public static final String DATABASE_NAME = "person.db";
public static final int VERSION = 1;
public static final String TABLE_NAME = "user";
public DBPersonOpenHelper(Context context) {
super(context, DATABASE_NAME, null, VERSION);
}
public DBPersonOpenHelper(Context context,int version) {
super(context, DATABASE_NAME, null, VERSION);
}
@Override
public void onCreate(SQLiteDatabase db) {
db.execSQL("create table +"+TABLE_NAME+"(uid INTEGER primary key autoincrement,name varchar(255),number varchar(255),province varchar(255),city varchar(255),zone varchar(255),school varchar(255),grade varchar(255),class varchar(255),messageinfo TEXT,sendtime varchar(255),receivetime varchar(255),dealnumber INTEGER,successnumber INTEGER,failNumber INTEGER )");
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
System.out.println("update a database");
String sql = "drop table "+TABLE_NAME;
db.execSQL(sql);
onCreate(db);
}