本帖最后由 sknice 于 2011-07-17 13:19:59 编辑

解决方案 »

  1.   

     PetTrackerDatabaseHelper mDatabase=new  PetTrackerDatabaseHelper(this.getApplicationContext());
    改成这样:
     PetTrackerDatabaseHelper mDatabase=new  PetTrackerDatabaseHelper(this);
    此方法API中是这么解释的
    public abstract Context getApplicationContext () 
    Since: API Level 1 Return the context of the single, global Application object of the current process. This generally should only be used if you need a Context whose lifecycle is separate from the current context, that is tied to the lifetime of the process rather than the current component. 
      

  2.   

    是不是你的数据库文件有问题
    把原来的db文件删除了
    PetTrackerDatabaseHelper的oncreate改成下面的 @Override
    public void onCreate(SQLiteDatabase db) {
      db.execSQL("create table pets (_id integer primary key autoincrement ,pet_name text,pet_type_id integer);");
      db.execSQL("insert into pets values(5,\"item1\",1);");
      db.execSQL("insert into pets values(6,\"item2\",2);");
      db.execSQL("insert into pets values(7,\"item3\",3);");
      db.execSQL("insert into pets values(8,\"item4\",4);");
      db.execSQL("insert into pets values(9,\"item5\",5);");
    }
      

  3.   

    把你数据库的实现看一下,看你query都做了什么,在query里面是不能close数据库的,要不然就会产生这种情况
      

  4.   


     貌似这样也行this.getApplicationContext()
      

  5.   

    5楼正解, 第一个字段是个特殊字段,列名称应该是 _id ,我的数据库写成了  id
      

  6.   

    5楼正解, 第一个字段是个特殊字段,列名称应该是 "_id" ,我的数据库写成了  "id"
      

  7.   

    5楼正解, 第一个字段是个特殊字段,列名称应该是 "_id" ,我的数据库写成了  "id"