Skip to content Skip to sidebar Skip to footer

Android: Nullpointerexception Unable To Load Database Into Listview Within A Fragment

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 come up w

Solution 1:

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.

Post a Comment for "Android: Nullpointerexception Unable To Load Database Into Listview Within A Fragment"