List is empty after uploading crime-database

I uploaded the databases folder at data/data/<package-name> and followed the instructions in the “Using LiveData” section. The build succeeds without errors, but the list displayed is empty. Upon logging the size of the list in the observer callback in onViewCreated in CrimeListFragment, I’m getting a list size of zero.

What did I do wrong?

I have uploaded the project here:

Thanks in advance!

I also tried running the app from the solution zip, still nothing (only an empty screen)

Not sure what went wrong, but I created the app from scratch again and it seemed to work this time. Although it was indeed weird that I couldn’t get the solutions zip (AndroidProgramming4e.zip) to work.

Was a solution ever figured out for this? I am running into the same issue… not sure what I’m doing wrong! Tried both the solution zip and created it from scratch again, nothing seems to work.

I do have the same issues here too. My list is empty and here’s my code:
crimeListViewModel.crimeListLiveData.observe(
viewLifecycleOwner,
Observer { crimes →
crimes?.let {
updateUI(crimes)
}

            })

It’s also suggested that the code should be in onCreateView(). Can someone really help resolve this.

Check if the DATABASE_NAME variable is the same as the file in data/data, I had this error because I had a stupid space before the string, if the file doesn’t exist, he will create a new one, without throwing errors

Hi Crysto. I have checked and they are the same. No space. I queried the DB on command prompt and was able to see all the records but the size of the list in CrimeListFragment is still 0. I am going crazy trying to figure out where the disconnect is.

In my case, the problem was caused by the implementation of the challenges in the same application. After removing the requiresPolice field, the application works as expected.

1 Like