0

I have used a constructor for SQLiteOpenHelper as given below: (I have already implemented onCreate() and onUpgrade() methods)

public class DB_todos extends SQLiteOpenHelper{

     DB_todos(Context context){
          super(context, DB_NAME, null, DB_VERSION);
  }
     ..........
}

The Runtime exception is: Exception Ljava/lang/NullPointerException; thrown while initializing Lapp/quicklook/DB_todos;

I am confused if the way i have used the constructor is legitimate. Please give your inputs to resolve this.

4

1 回答 1

0

您在访问数据库之前是否正确打开了数据库?您应该在 OnCreate() 开始时打开数据库 [ds.open(),在 OnCreate() 结束时打开 ds.close()]

于 2013-10-23T19:21:34.253 回答