package com.tsh.database;
import android.content.Context;
android.database.sqlite.sqliteDatabase;
android.database.sqlite.sqliteOpenHelper;
public class PersonsqliteOpenHelper extends sqliteOpenHelper {
/**
* 构造方法
* @param context
*/
public PersonsqliteOpenHelper(Context context) {
super(context,"person.db",null,1);
}
* 数据库第一次创建完成的回调
*/
@Override
void onCreate(sqliteDatabase db) {
String sql="create table person (id integer primary key autoincrement,name varchar(10) not null default '')";
db.execsql(sql);
}
@Override
void onUpgrade(sqliteDatabase db,1)">int oldVersion,1)">int newVersion) {
// TODO Auto-generated method stub
}
}
com.tsh.database.test;
com.tsh.database.PersonsqliteOpenHelper;
android.test.AndroidTestCase;
class TestPersonDb AndroidTestCase {
void testPerson() throws Exception{
PersonsqliteOpenHelper helper =new PersonsqliteOpenHelper(getContext());
helper.getWritableDatabase();
}
}