NullPointerException when trying to insert into SQLite - Android

前端 未结 2 1286
小鲜肉
小鲜肉 2021-01-25 11:13

Anyone who follows Android tags are probably familiar with me. I am having the hardest time implementing a SQLite database for my highscores. This is also my first time workin

2条回答
  •  终归单人心
    2021-01-25 11:38

    Instead of

    dh.openDB(db);
    

    say

    db = dh.openDB(db);
    

    (although the openDB method really doesn't need to have an argument). Your call to openDB doesn't store the database object reference in db, so it's NULL when you get around to calling dh.insert(..., db);.

提交回复
热议问题