Basic navigation and database

In the second class we create a new AddPlaceFragment and set up a navigation for it. The navigation uses NavigationCompoment.

The other part of the class was dedicated to creating a database. On Android, we can use a Room library to create an easy access to the database.

The database is composed on several classes:

  • PlacesDatabase — main database class. Inherits from the RoomDatabase class.
  • PlacesDao — defines the interface of operations over the database.
  • PlacesLocalRepository — another layer between the Dao and fragment.

We have also mentioned new thing called suspend function. Suspend function perform something in the background thread. The reason is not to block UI thread.

--

--