本帖最后由 wlianghe00 于 2012-02-01 16:43:41 编辑

解决方案 »

  1.   

    SQliteOpenHelper是一个抽象类,来管理数据库的创建和版本的管理。要使用它必须实现它的nCreate(SQLiteDatabase),onUpgrade(SQLiteDatabase, int, int)方法  onCreate:当数据库第一次被建立的时候被执行,例如创建表,初始化数据等。  onUpgrade:当数据库需要被更新的时候执行,例如删除久表,创建新表。
    (Context  getApplicationContext(),......);
      

  2.   


    在oncreate方法里面插入数据吗,那没有数据库的名字啊
      

  3.   

    onUpgrade:当数据库需要被更新的时候执行你说的插入应在这里
      

  4.   


    public class DBHelper extends SQLiteOpenHelper{
    final String CREATE_TABLE_SQL="create table Filter_Type(_id Integer primary key, filter_name,description)";
    final String CREATE_TABLE_FILTER_SET="create table Filter_Set" +
    "(_id Integer primary key autoincrement, phone_num,link_man," +
    "filter_type,description);";
    /**
     * 在数据库下创建表结构
     */
    @Override
    public void onCreate(SQLiteDatabase db) {
    if(db!=null){
    //设置拦截号码数据库
    //db.execSQL("create table Filter_Set(_id integer PRIMARY KEY AUTOINCREMENT,phone_num shrot,filter_type integer,description text)");
    //拦截信息数据库
    db.execSQL("create table Filter_Record(_id integer PRIMARY KEY AUTOINCREMENT, filter_num shrot,filter_time datatime,filter_content text,filter_mold integer,filter_read integer)");
    //第一次使用数据库是自动创建表
    db.execSQL(CREATE_TABLE_SQL);//拦截对象表
    db.execSQL(CREATE_TABLE_FILTER_SET);//拦截设置表
    db.execSQL("insert into Filter_Type(_id,filter_name) values(0,'来电+短信')");
    db.execSQL("insert into Filter_Type(_id,filter_name) values(1,'来电')");
    db.execSQL("insert into Filter_Type(_id,filter_name) values(2,'短信')");这不就加进去了
      

  5.   

    给你个链接 你看看就明白了
    http://code.google.com/p/androidlearn/wiki/SQLiteOpenHelper