Android SQLite Null Pointer Exception

后端 未结 2 1066
礼貌的吻别
礼貌的吻别 2021-01-04 04:14

I am getting this in LogCat:

05-20 17:16:34.721: E/AndroidRuntime(30461): FATAL EXCEPTION: main
05-20 17:16:34.721: E/AndroidRuntime(30461): java.lang.NullPo         


        
2条回答
  •  清歌不尽
    2021-01-04 04:55

    Looks like your trying to access the db when it's been closed. Perhaps placing datasource.open() at the beginning of onCreate and datasource.close() at the end of onCreate() and calling them each just once in your class would solve your problem.

    If you are editing, creating and deleting items in your activity requiring multiple calls to your database, consider calling datasource.open() at the beginning of a method that accesses the database and then close() at the end of of that method.

提交回复
热议问题