SQLite的使用示例

public class CoolWeatherOpenHelper extends SQLiteOpenHelper {

/**
* Province表建表语句
*/

public static final String CREATE_PROVINCE="create table Province("

                             +"id integer primary key autoincrement,"

                             +"city_name text,"

                               +"province_id integer)";

//构造方法 四个参数: context, name, factory,version

public CoolWeatherOpenHelper(Context context, String name, CursorFactory factory, int version){

super(context,name,factory,version);

@override

public void onCreate(SQLiteDatebase db){

db.execSQL(CREATE_PROVINCE);//创建Province表

}

@Override

public void onUpgrade(SQLiteDatabase db, int oldVersion,int newVersion){

super(context,name,factory,version);}

}

posted @ 2016-04-28 15:16  gentspy  阅读(141)  评论(0编辑  收藏  举报