Android: NullPointerException Unable to load database into listview within a fragment

后端 未结 1 650
刺人心
刺人心 2020-12-22 10:56

I\'ve been searching for a while trying to find how to populate a listview with information from the MySQLite database. Now when I think I finally found some information I c

相关标签:
1条回答
  • 2020-12-22 11:07

    The line final DatabaseHandler db = new DatabaseHandler(getActivity()); is declared at the top of your class and so on creation of your Fragment getActivity() will return a null reference.

    If you move it inside the onCreate() method you will have an Activity reference your db handler can use.

    0 讨论(0)
提交回复
热议问题