/*
一、创建一个类MySQLiteOpenHelper继承SQLiteOpenHelper,实现onCreate和onUpgrade
方法。
二、创建常量类Constant,将库名表名之类的写进去。
public class Constant {
public static final String DASEBASE_NAME = "user.db";
public static final int VERSION = 1;
public static final String TABLE_NAME = "students";
public static final String _ID = "_id";
public static final String STUDENT_NAME = "name";
public static final String STUDENT_SEX = "sex";
public static final String STUDENT_AGE = "age";
}
三、创建数据库管理类,用单例模式获得帮助类实例。
public class DbManger {
private static MySQLiteOpenHelper helper;
public static MySQLiteOpenHelper getIntance(Context context) {
if (helper == null) {
helper = new MySQLiteOpenHelper(context);
}
return helper;
}
}
四、创建数据库
private MySQLiteOpenHelper helper;
helper = DbManger.getIntance(this);
SQLiteDatabase db = helper.getWritableDatabase();
*/